Skip to content

[camera_android_camerax][tool] Integrate dart_code_linter for cyclomatic complexity checks#11999

Merged
auto-submit[bot] merged 26 commits into
flutter:mainfrom
reidbaker:add-cyclomatic-complexity-linter
Jul 1, 2026
Merged

[camera_android_camerax][tool] Integrate dart_code_linter for cyclomatic complexity checks#11999
auto-submit[bot] merged 26 commits into
flutter:mainfrom
reidbaker:add-cyclomatic-complexity-linter

Conversation

@reidbaker

@reidbaker reidbaker commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Enables cyclomatic complexity enforcement in camera_android_camerax by integrating dart_code_linter: 4.1.5 as 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_complexity package. However, we encountered a dependency conflict that blocked its integration:

  • dart_cognitive_complexity: 2.0.0 requires analyzer: ^13.0.0.
  • The repository dependencies (specifically pigeon) restrict the resolved version of analyzer to <13.0.0 (which resolves to 10.0.1).
  • Upgrading pigeon to a published version would not work since no version on pub.dev supports analyzer: ^13.0.0.
  • Upgrading pigeon code felt out of scope for this effort.
  • Downgrading to dart_cognitive_complexity: 1.0.1 is also not possible because it requires analyzer: <7.0.0 (which conflicts with pigeon's requirement of >=10.0.0).

Pre-Review Checklist

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 25, 2026
@reidbaker reidbaker added override: no versioning needed Override the check requiring version bumps for most changes override: no changelog needed Override the check requiring CHANGELOG updates for most changes labels Jun 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread script/configs/custom_analysis.yaml Outdated
Comment thread script/tool/lib/src/analyze_command.dart Outdated
Comment thread script/tool/test/analyze_command_test.dart Outdated
Comment thread script/tool/test/analyze_command_test.dart Outdated
Comment thread script/tool/test/analyze_command_test.dart Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 25, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 25, 2026
@reidbaker

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread script/tool/lib/src/analyze_command.dart Outdated
@reidbaker reidbaker removed the request for review from stuartmorgan-g June 25, 2026 19:31
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 25, 2026
@stuartmorgan-g

Copy link
Copy Markdown
Collaborator
  • Upgrading pigeon code felt out of scope for this effort.

FYI I just bumped the priority on updating Pigeon to support the latest analyzer.


dev_dependencies:
build_runner: ^2.2.0
dart_code_linter: 4.1.5

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've audited this as safe to run in our CI and locally?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@reidbaker reidbaker Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 camsim99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM % unresolved comments!

@reidbaker reidbaker added the CICD Run CI/CD label Jul 1, 2026
@flutter-dashboard

Copy link
Copy Markdown

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.

@github-actions github-actions Bot removed the CICD Run CI/CD label Jul 1, 2026
@reidbaker reidbaker added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Jul 1, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 1, 2026
@auto-submit

auto-submit Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot removed the CICD Run CI/CD label Jul 1, 2026
@reidbaker reidbaker added the CICD Run CI/CD label Jul 1, 2026
@reidbaker

reidbaker commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

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.

@reidbaker reidbaker added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 1, 2026
@auto-submit auto-submit Bot merged commit e95aa21 into flutter:main Jul 1, 2026
89 checks passed
pull Bot pushed a commit to Klomgor/flutter that referenced this pull request Jul 2, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD override: no changelog needed Override the check requiring CHANGELOG updates for most changes override: no versioning needed Override the check requiring version bumps for most changes p: camera

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants