[camera_android_camerax][tool] Integrate dart_code_linter for cyclomatic complexity checks#11999
Conversation
…ols analyze command
…ng to the runner loop
…ole output for all scenarios
…sing helper functions
…sserting absence of case-insensitive keywords
There was a problem hiding this comment.
Code Review
This pull request integrates the dart_code_linter tool into the repository's analysis command to check cyclomatic complexity for the camera_android_camerax package, updating configuration files, the analysis script, and adding corresponding tests. Feedback suggests correcting a comment mismatch from "cognitive" to "cyclomatic" complexity, and simplifying the linter execution by consistently using dart run instead of conditionally invoking flutter pub run, which also requires updating the associated unit tests and helper methods.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request integrates the dart_code_linter tool into the repository's analysis command, enabling custom linter checks during package analysis when the dependency is declared in dev_dependencies. The linter is configured for camera_android_camerax with a cyclomatic complexity threshold of 15, and corresponding unit tests are added. Feedback suggests adding a defensive check to ensure the lib/ directory exists before running the linter to prevent errors on packages without a library directory.
…es lacking a lib/ directory
FYI I just bumped the priority on updating Pigeon to support the latest |
|
|
||
| dev_dependencies: | ||
| build_runner: ^2.2.0 | ||
| dart_code_linter: 4.1.5 |
There was a problem hiding this comment.
You've audited this as safe to run in our CI and locally?
There was a problem hiding this comment.
SHA1 (dart_code_linter-4.1.5.tar.gz) = 86fa1bd240a88c98a4c45f0beb43b4e7adb32735
For auditability this this is the artifact I inspected.
Looking at the code I didn't see anything suspicious.
Some things I found but I do not think are blocking:
It uses https://pub.dev/packages/pub_updater to see if there is a newer version. It works without internet access.
There is a python script to make cursor skills. It is for contributors but I found that interesting.
There was a problem hiding this comment.
As concrete examples of suspicious things I looked for. Code that tried to spawn other process, code that tried to install other things, network calls, code that read env variables that looked like secrets.
| final bool hasDependency = pubspec.devDependencies.containsKey(runner.dependencyName); | ||
| if (hasDependency) { | ||
| final PackageResult result = await runner.run(package); | ||
| if (result.state == RunState.failed) { |
There was a problem hiding this comment.
The strongly preferred pattern in the repo tooling is for the helper functions to return List<String> representing any errors (such than an empty array is success), and for the loop to aggregate the errors into a local errors array, then at the end to return errors.isEmpty ? PackageResult.success() : PackageResult.fail(errors);
That way, we get all the results in every run, rather than only up to the first failing thing.
There was a problem hiding this comment.
Yes sorry, I authored this pr at the same time as the other one you gave this feedback on and I didnt go back to check if the pattern was violated anywhere else.
I also filed flutter/flutter#188867 which tracks changing the gradle behavior to follow this pattern.
I will personally try to remember this pattern and I have taken steps on my local machine to try to ensure this pattern does not pop up again.
camsim99
left a comment
There was a problem hiding this comment.
Overall LGTM % unresolved comments!
|
This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled. |
|
autosubmit label was removed for flutter/packages/11999, because - The status or check suite Linux analyze_downgraded stable has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…nning file dependency" This reverts commit 002182d.
|
the changes in b934bf8 add logic to no longer run the custom linters on --downgrade it caused an issue and the downgrade evals are for api compatibility. |
…er#188916) flutter/packages@e742106...420e135 2026-07-02 dkwingsmt@users.noreply.github.com [material_ui] Migrate api sample code to @example dartdoc directive (flutter/packages#12078) 2026-07-02 dkwingsmt@users.noreply.github.com [material_ui] Move over more API samples (flutter/packages#12092) 2026-07-01 katelovett@google.com [cupertino_ui] Migrate api sample code to @example dartdoc directive (flutter/packages#12063) 2026-07-01 katelovett@google.com [cupertino_ui] Move over more API samples (flutter/packages#12086) 2026-07-01 48776784+mackings@users.noreply.github.com [two_dimensional_scrollables] Fix TreeView horizontal hit testing (flutter/packages#11859) 2026-07-01 1063596+reidbaker@users.noreply.github.com [camera_android_camerax][tool] Integrate dart_code_linter for cyclomatic complexity checks (flutter/packages#11999) 2026-07-01 dinurymomshad.dev@gmail.com [cross_file] Add runnable example with main() (flutter/packages#11527) 2026-07-01 36861262+QuncCccccc@users.noreply.github.com [cupertino_ui] Enable `switch_test.dart` (flutter/packages#12076) 2026-07-01 jmccandless@google.com [cupertino_ui] Re-enable dialog_test.dart (flutter/packages#12057) 2026-07-01 jmccandless@google.com [cupertino_ui] Re-enable action_sheet_test.dart (flutter/packages#12055) 2026-07-01 rmolivares@renzo-olivares.dev [cupertino_ui] Migrate `bottom_tab_bar_test.dart` to `SemanticsHandle` (flutter/packages#12012) 2026-07-01 1063596+reidbaker@users.noreply.github.com [repo] Add comment style guideline to AGENTS.md (flutter/packages#12077) 2026-07-01 43054281+camsim99@users.noreply.github.com Adds pre-push readiness skill (flutter/packages#11935) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Enables cyclomatic complexity enforcement in
camera_android_cameraxby integratingdart_code_linter: 4.1.5as a CLI linter check within the repository analysis tooling.No issue this is part of the work for project oneshot.
Changelog/Version not needed changes are to shared tooling and specifically linters enabled for camera_android_camerax.
FWIW
We (@camsim99 and myself) initially aimed to enforce cognitive complexity using the
dart_cognitive_complexitypackage. However, we encountered a dependency conflict that blocked its integration:dart_cognitive_complexity: 2.0.0requiresanalyzer: ^13.0.0.pigeon) restrict the resolved version ofanalyzerto<13.0.0(which resolves to10.0.1).pigeonto a published version would not work since no version on pub.dev supportsanalyzer: ^13.0.0.pigeoncode felt out of scope for this effort.dart_cognitive_complexity: 1.0.1is also not possible because it requiresanalyzer: <7.0.0(which conflicts withpigeon's requirement of>=10.0.0).Pre-Review Checklist
[shared_preferences]///).