Skip to main content

avoid-excessive-expressions

added in: 1.14.0

Warns when a condition has excessive expressions.

Example

❌ Bad:

void fn() {
final num = 1;
final anotherNum = 2;

if (anotherNum == 3 && anotherNum != 4) {} // LINT
if (num != null && num is int) {} // LINT
if (num == null || num is! int) {} // LINT
if (5 < anotherNum && anotherNum > 4) {} // LINT
}

✅ Good:

void fn() {
final num = 1;
final anotherNum = 2;

if (anotherNum != 3 && anotherNum != 4) {}
if (num is int) {}
if (num is! int) {}
if (2 < anotherNum && anotherNum < 4) {}
}