Skip to content

Add new rule avoid_similar_names#321

Open
solid-illiaaihistov wants to merge 9 commits into
solid-software:analysis_server_migrationfrom
solid-illiaaihistov:95-add-avoid_similar_names
Open

Add new rule avoid_similar_names#321
solid-illiaaihistov wants to merge 9 commits into
solid-software:analysis_server_migrationfrom
solid-illiaaihistov:95-add-avoid_similar_names

Conversation

@solid-illiaaihistov

Copy link
Copy Markdown
Collaborator

Closes #95

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/src/lints/avoid_similar_names/utils/name_tokenizer.dart Outdated
Comment thread lib/src/lints/avoid_similar_names/visitors/avoid_similar_names_visitor.dart Outdated
@solid-illiaaihistov

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/src/lints/avoid_similar_names/visitors/avoid_similar_names_visitor.dart Outdated
@solid-illiaaihistov

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/src/lints/avoid_similar_names/avoid_similar_names_rule.dart
@solid-illiaaihistov

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/src/lints/avoid_similar_names/utils/name_tokenizer.dart
Comment thread lib/src/lints/avoid_similar_names/avoid_similar_names_rule.dart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant