[camera_android_camerax][tool] Migrate complexity checks to package:cognitive_complexity - #12356
Draft
reidbaker-agent wants to merge 3 commits into
Draft
[camera_android_camerax][tool] Migrate complexity checks to package:cognitive_complexity#12356reidbaker-agent wants to merge 3 commits into
reidbaker-agent wants to merge 3 commits into
Conversation
…ognitive_complexity Migrates codebase complexity enforcement for camera_android_camerax from dart_code_linter (cyclomatic complexity) to package:cognitive_complexity (cognitive complexity), matching the migration in flutter/agent-plugins#211 and replacing flutter#11999. - Replaces dart_code_linter with cognitive_complexity under pinned allowed dependencies in .repo_tool_config.yaml. - Updates AnalyzeCommand in script/tool/lib/src/analyze_command.dart to execute cognitive_complexity with configured fail thresholds from analysis_options.yaml while filtering out generated Dart files (.g.dart, .freezed.dart, .mocks.dart, .gen.dart). - Replaces dart_code_linter with cognitive_complexity: 0.2.0 in packages/camera/camera_android_camerax/pubspec.yaml and configures fail-threshold: 15 in analysis_options.yaml. - Adds dependency_overrides for analyzer: ^14.1.0 and file: ^7.0.1 to resolve version constraints alongside pigeon. - Updates repository tooling unit tests in script/tool/test/analyze_command_test.dart to test cognitive_complexity and verify generated file exclusion.
reidbaker
reviewed
Aug 4, 2026
Comment on lines
+371
to
+373
| filePath.endsWith('.freezed.dart') || | ||
| filePath.endsWith('.mocks.dart') || | ||
| filePath.endsWith('.gen.dart'); |
Contributor
There was a problem hiding this comment.
Are all of these file types present in this codebase? if not then remove the matchers that do not match at least one expected file in this repo.
| 'cognitive_complexity', | ||
| if (threshold != null) ...<String>[ | ||
| '--threshold', | ||
| (threshold > 5 ? threshold - 5 : 0).toString(), |
Contributor
There was a problem hiding this comment.
Why is this threshold logic variable?
… document threshold logic - Removes .freezed.dart from _isGeneratedDartFile in script/tool/lib/src/analyze_command.dart as .freezed.dart is not present in flutter/packages. - Adds explanatory comment for setting --threshold to max(0, threshold - 5) when --fail-threshold is configured. - Updates analyze_command_test.dart generated file test to use .mocks.dart and .gen.dart.
…ns are printed Sets --threshold equal to threshold when --fail-threshold is configured so that cognitive_complexity only outputs declarations that violate the failure threshold.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When we initially added cyclomatic complexity we wanted cognitive complexity. Now there is a mit licensed version that meets our dependency constraints maintained by a flutter contributor so let's migrate to that.
PR is in draft pending updates to kevmoo/cognitive_complexity.dart#10 which lowers the analyzer bounds so this pr can get rid of the overrides.
Agent authored pr description
Migrates codebase complexity enforcement for
camera_android_cameraxfromdart_code_linter(cyclomatic complexity) topackage:cognitive_complexity(cognitive complexity), matching the migration in flutter/agent-plugins#211 and replacing #11999.Summary
dart_code_linterwithcognitive_complexityunderpinnedallowed dependencies in.repo_tool_config.yaml.AnalyzeCommandinscript/tool/lib/src/analyze_command.dartto executecognitive_complexitywith configured fail thresholds fromanalysis_options.yamlwhile filtering out generated Dart files (.g.dart,.freezed.dart,.mocks.dart,.gen.dart).dart_code_linterwithcognitive_complexity: 0.2.0inpackages/camera/camera_android_camerax/pubspec.yamland configuredfail-threshold: 15inanalysis_options.yaml.dependency_overridesforanalyzer: ^14.1.0andfile: ^7.0.1to resolve version constraints alongsidepigeon.script/tool/test/analyze_command_test.dartto testcognitive_complexityand verify generated file exclusion.Pre-Review Checklist
[shared_preferences]///).