refactor: migrate cyclomatic_complexity#294
Conversation
…o 250-migrate-cyclomatic_complexity
…and remove obsolete issue link
There was a problem hiding this comment.
Code Review
This pull request refactors the cyclomatic_complexity lint rule to use the updated analyzer APIs, replacing the token-based matching in CyclomaticComplexityFlowVisitor with node-specific AST visitors and introducing a new CyclomaticComplexityVisitor. It also replaces the old test file with a comprehensive suite of unit tests. The review feedback highlights a compilation error due to a non-existent property on LintCode, and suggests extending the complexity checks to cover constructor declarations and do-while loops.
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.
… and add additional test cases
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the cyclomatic_complexity lint rule to use the new RuleVisitorRegistry and RuleContext API. It replaces the token-based block visitor with a structured AST visitor (CyclomaticComplexityVisitor and CyclomaticComplexityFlowVisitor) that handles various Dart language constructs such as switch expressions, patterns, and logical operators, while correctly ignoring nested functions and closures. Additionally, a comprehensive test suite has been added. Feedback suggests extending the complexity calculation to support collection elements (IfElement and ForElement) and adding corresponding test cases.
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.
…perators in cyclomatic complexity calculation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the CyclomaticComplexityRule to use the updated analyzer API (RuleVisitorRegistry and RuleContext). It introduces a new CyclomaticComplexityVisitor to traverse function, constructor, and method declarations, and updates CyclomaticComplexityFlowVisitor to support modern Dart features (such as switch expressions, patterns, null-aware cascades, and spreads) while stopping recursion into nested functions or closures. Comprehensive tests have also been added. The reviewer suggests further improving the accuracy of the cyclomatic complexity metric by counting NullCheckPattern and NullAssertPattern as complexity-increasing entities.
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 refactors the cyclomatic complexity lint rule to use the updated analyzer APIs and significantly expands its coverage to support Dart 3 features such as switch expressions, patterns, collection elements, and null-aware operators. It also replaces the old test file with a robust suite of unit tests. The review feedback suggests a key performance optimization: instead of using a recursive visitor over the entire compilation unit, the rule should register node processors directly for function, constructor, and method declarations, which would also allow the removal of the redundant CyclomaticComplexityVisitor class.
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.
There was a problem hiding this comment.
Code Review
This pull request refactors the cyclomatic complexity lint rule to use the new analyzer API, moving the logic into CyclomaticComplexityVisitor and CyclomaticComplexityFlowVisitor. It also expands the AST nodes that contribute to complexity (such as switch expressions, patterns, null-aware cascades, and spreads) and adds comprehensive unit tests. The review feedback suggests supporting cyclomatic complexity checks for anonymous closures by overriding visitFunctionExpression instead of visitFunctionDeclaration in CyclomaticComplexityVisitor, which ensures complex closures are not ignored while still respecting exclusion rules.
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.
There was a problem hiding this comment.
Code Review
This pull request refactors the cyclomatic_complexity lint rule to use the updated analyzer APIs (RuleVisitorRegistry and RuleContext) and introduces a more robust AST visitor structure (CyclomaticComplexityVisitor and CyclomaticComplexityFlowVisitor) to accurately calculate cyclomatic complexity across various Dart language features. It also replaces the old test file with a comprehensive reflective test suite. The review feedback suggests extending the complexity visitor to account for null-aware function expression invocations (e.g., func?.()) and adding a corresponding test case to verify this behavior.
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.
…nd target individual declaration types
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the CyclomaticComplexityRule to use the newer analyzer APIs (RuleVisitorRegistry and RuleContext) and introduces a new CyclomaticComplexityVisitor to traverse declarations. The CyclomaticComplexityFlowVisitor has been updated to visit a wider range of AST nodes (such as switch expressions, patterns, collection elements, and null-aware operators) to compute cyclomatic complexity. Feedback points out that ForEachStatement (for-in loops) is currently unhandled by the visitor, meaning their complexity is ignored. It is recommended to override visitForEachStatement and add corresponding test coverage.
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 #250