Add new rule avoid_similar_names#321
Conversation
… in avoid_similar_names lint
There was a problem hiding this comment.
Code Review
This pull request introduces a new lint rule, avoid_similar_names, which warns about variables or parameters with confusingly similar names within the same function scope. It includes the rule implementation, AST visitors, tokenization utilities, and corresponding tests. The feedback highlights three key areas for improvement: refining the tokenization regular expression to correctly handle acronyms followed by capitalized words, extending LocalVariablesVisitor to collect variables from for-in loops, and adjusting the type comparison logic to allow comparisons between nullable and non-nullable versions of the same type.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…ort camelCase suffixes
…e collection logic
…es when comparing variable types
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new lint rule avoid_similar_names to detect confusingly similar variable and parameter names within the same scope. The feedback highlights two important improvements: changing the visitor base class to SimpleAstVisitor to avoid double-traversal performance issues, and extending LocalVariablesVisitor to support Dart 3.0 pattern variable declarations.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
… in AvoidSimilarNamesVisitor
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new lint rule, avoid_similar_names, which warns about variables or parameters with confusingly similar names within the same function scope. Feedback on the changes highlights a potential memory leak in AvoidSimilarNamesVisitor due to _reportedNodes never being cleared, and suggests registering FunctionExpression instead of FunctionDeclaration to support analyzing anonymous closures as well as named functions.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…tale lint reports
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new lint rule, avoid_similar_names, to detect variables or parameters with confusingly similar names within the same function scope. The feedback recommends adding an explicit length check in isSubsetWithNonDescriptiveToken to prevent potential out-of-bounds errors. Additionally, it suggests registering and visiting FunctionExpression instead of FunctionDeclaration to extend the analysis to anonymous closures.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
… adding related tests
Closes #95