cognitive_complexity 0.2.2+1 copy "cognitive_complexity: ^0.2.2+1" to clipboard
cognitive_complexity: ^0.2.2+1 copied to clipboard

Algorithmic Cognitive Complexity calculation and Data-Flow analysis library and CLI tools for Dart and Flutter.

0.2.2+1 #

  • Update the dart-cognitive-complexity agent skill: anti-goodhart 3-tier decomposition rubric with deterministic tier selection via the data_flow CLI, and a gated Tier 3 method-object reference (references/method-object.md) absorbed from kevmoo/kevmoo_skills.
  • No library or CLI code changes.

0.2.2 #

  • Introduce data_flow analysis tool and library (package:cognitive_complexity/data_flow.dart):
    • Added DataFlowAnalyzer to extract reaching definitions (inputs), variable mutations, and live outputs for arbitrary statement slices.
    • Added SignatureSynthesizer to automatically generate Dart 3 Record method signatures (({TypeA a, TypeB b})).
    • Added data_flow CLI with agent-first JSON formatting by default and formatted text reports.
    • Hardened slice analysis: pattern assignments ((a, b) = (b, a)), pattern variable declarations, labeled break/continue targeting outside the slice, rethrow whose catch lies outside the slice, mutations of captured variables inside nested closures, and constructor initializers.
    • Added ControlFlowEscapeType.closureEscape, rethrowEscape, and constructorInitializerEscape.
    • Signatures now propagate await for async-ness, use use-site static types (preserving promotion), include enclosing type parameters with their bounds, and sanitize/deduplicate record field names.
    • Liveness now follows loop back edges: a variable mutated in a slice inside a loop is reported as an output when it is read anywhere in that loop, even textually before the slice.

0.2.1 #

  • Broaden analyzer compatibility to support versions 12.x through 14.x.

0.2.0 #

Scoring fixes aligning with the SonarSource Cognitive Complexity whitepaper (v1.7) and its reference implementation (sonar-java):

  • else if chains no longer deepen nesting: branch contents sit one level below the head if (previously each chain link added an extra level).
  • switch statements/expressions and catch clauses now receive the standard nesting increment when nested (previously flat +1).
  • Local function declarations no longer add a structural +1; like lambdas, they only deepen nesting.

Analyzer coverage and CLI fixes:

  • Constructor initializers and parameter default values are now scored.
  • Top-level functions named with pseudo-keywords (show, on, ...) are no longer skipped.
  • Top-level getters/setters are reported with a get /set prefix, matching class members.
  • --fail-on-increase no longer flags newly added declarations (they have no baseline); they are governed by --fail-threshold alone.
  • Directory exclusion (.git, .dart_tool, build) now matches whole path segments, so .github/ and similar directories are scanned correctly.

0.1.0 #

  • Initial version.
1
likes
140
points
754
downloads

Documentation

API reference

Publisher

verified publisherkevmoo.com

Weekly Downloads

Algorithmic Cognitive Complexity calculation and Data-Flow analysis library and CLI tools for Dart and Flutter.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

analyzer, args, io, path, pool, stack_trace

More

Packages that depend on cognitive_complexity