dart_cognitive_complexity 2.0.0
dart_cognitive_complexity: ^2.0.0 copied to clipboard
A cognitive complexity linter for Dart libraries or applications.
dart_cognitive_complexity #
A cognitive complexity linter for Dart libraries or applications.
This plugin runs inside the Dart analysis server via
analysis_server_plugin,
with the complexity metric ported from
eslint-plugin-sonarjs.
Install #
Add the package as a dev dependency:
dev_dependencies:
dart_cognitive_complexity:
Activate the plugin in your analysis_options.yaml:
analyzer:
plugins:
- dart_cognitive_complexity
Config #
Configure the threshold under a top-level cognitive_complexity: block in
analysis_options.yaml:
analyzer:
plugins:
- dart_cognitive_complexity
cognitive_complexity:
threshold: 15 # default 10
To change the severity, use the analyzer's standard mechanism:
analyzer:
errors:
cognitive_complexity: warning # info | warning | error
Running #
The diagnostics show up in any tool that talks to the analysis server
(dart analyze, your IDE, etc.) — no separate runner is needed.
Migrating from 1.x #
Version 2.0 dropped custom_lint_builder. To migrate:
- Remove
custom_lintfrom your dev dependencies and fromanalyzer.plugins:. - Add
dart_cognitive_complexitydirectly underanalyzer.plugins:. - Move the rule options from the
custom_lint:block to a top-levelcognitive_complexity:block. - Replace any
severity:setting with the standardanalyzer.errors:block.