feat: add use_nearest_context rule (#190)#293
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the use_nearest_context lint rule along with two quick fixes (RenameNearestContextParameterFix and ReplaceWithNearestContextParameterFix) to ensure BuildContext is accessed from the nearest available scope. It also updates isBuildContext to support nullable types and includes comprehensive unit tests. The review feedback highlights two important improvements: first, ReplaceWithNearestContextParameterFix should be extended to handle direct usage of context (not just property accesses on this); second, the visitor can be simplified by using element.nameOffset directly to avoid an unnecessary null check.
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.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the use_nearest_context lint rule, which encourages using the BuildContext from the nearest available scope. It includes the rule implementation, a visitor, utility functions, unit tests, and two quick fixes: RenameNearestContextParameterFix and ReplaceWithNearestContextParameterFix. The feedback highlights an issue in the ReplaceWithNearestContextParameterFix where plain SimpleIdentifiers (like plain context usage) are not replaced, and suggests adding a fallback. Additionally, it recommends simplifying the scope check in UseNearestContextVisitor by using element.nameOffset directly to avoid null checks.
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.
Closes #190