Add use_nearest_context lint rule (#190)#288
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the use_nearest_context lint rule and its corresponding quick fix, which ensures that BuildContext is used from the nearest available scope. The feedback highlights two critical issues: first, the quick fix is currently broken for anonymous functions and builders because it only registers listeners for FunctionDeclaration and MethodDeclaration instead of applying the replacement directly; second, the lint rule suffers from several false positives, such as triggering on variable declarations, named argument labels, and properties of other objects, which need to be explicitly ignored.
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.
…simplify quick fix logic
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new lint rule, use_nearest_context, which ensures that BuildContext is accessed from the nearest available scope in Flutter applications. It includes the rule implementation, a corresponding quick fix to rename the context parameter, integration into the linter package, and comprehensive test cases. The feedback recommends simplifying the analyzer API usage in use_nearest_context_rule.dart by using element.nameOffset and declaredElement?.type directly, which eliminates unnecessary null checks and fragment traversals.
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