Why this matters
Using `is!` instead of `!is` avoids confusion with null assertion syntax and improves code clarity.
Use `is!` instead of `!is` for type checking to prevent confusion and ensure consistent behavior.
Using `is!` instead of `!is` avoids confusion with null assertion syntax and improves code clarity.
Side-by-side examples engineers can pattern-match during review.
void main(dynamic s) {
if (s !is String) { // Noncompliant
print('s is not a String!');
}
}void main(dynamic s) {
if (s is! String) {
print('s is not a String!');
}
}void main(dynamic s) {
if (s !is String) { // Noncompliant
print('s is not a String!');
}
}void main(dynamic s) {
if (s is! String) {
print('s is not a String!');
}
}From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.