dart_cognitive_complexity 2.0.0 copy "dart_cognitive_complexity: ^2.0.0" to clipboard
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_lint from your dev dependencies and from analyzer.plugins:.
  • Add dart_cognitive_complexity directly under analyzer.plugins:.
  • Move the rule options from the custom_lint: block to a top-level cognitive_complexity: block.
  • Replace any severity: setting with the standard analyzer.errors: block.
5
likes
140
points
126
downloads

Documentation

API reference

Publisher

verified publisheroursky.com

Weekly Downloads

A cognitive complexity linter for Dart libraries or applications.

Repository (GitHub)
View/report issues

License

LGPL-3.0 (license)

Dependencies

analysis_server_plugin, analyzer, path, yaml

More

Packages that depend on dart_cognitive_complexity