Skip to main content

avoid_similar_names

Avoid similar names

Warns about variables or parameters that have confusingly similar names within the same function scope (e.g., using numeric suffixes or single-letter modifiers like someClass1 and someClass2).

This encourages using descriptive, distinct names to improve code readability and prevent logical errors caused by mixing up variables.

Example

BAD:

void test(SomeClass someClass1, SomeClass someClass2) { // LINT
final tempA = 'a'; // LINT
final tempB = 'b'; // LINT
}

GOOD:

void test(SomeClass first, SomeClass second) {
final that = 'a';
final other = 'b';
}