prefer-returning-condition
Suggests to directly return the condition from the previous if statement.
Example
❌ Bad:
void fn(bool condition, bool anotherCondition) {
if (condition) {
return true;
}
// LINT: Prefer returning a merged condition from the previous if statement and its inner return.
return false;
}
void fn(bool condition, bool anotherCondition) {
if (condition) {
return anotherCondition;
}
// LINT: Prefer returning a merged condition from the previous if statement and its inner return.
return false;
}
✅ Good:
void fn(bool condition, bool anotherCondition) {
return condition;
}
void fn(bool condition, bool anotherCondition) {
return condition && anotherCondition;
}