cognitive_complexity 0.2.2
cognitive_complexity: ^0.2.2 copied to clipboard
Algorithmic Cognitive Complexity calculation and Data-Flow analysis library and CLI tools for Dart and Flutter.
0.2.2 #
- Introduce
data_flowanalysis tool and library (package:cognitive_complexity/data_flow.dart):- Added
DataFlowAnalyzerto extract reaching definitions (inputs), variable mutations, and live outputs for arbitrary statement slices. - Added
SignatureSynthesizerto automatically generate Dart 3 Record method signatures (({TypeA a, TypeB b})). - Added
data_flowCLI with agent-first JSON formatting by default and formatted text reports. - Hardened slice analysis: pattern assignments (
(a, b) = (b, a)), pattern variable declarations, labeledbreak/continuetargeting outside the slice,rethrowwhosecatchlies outside the slice, mutations of captured variables inside nested closures, and constructor initializers. - Added
ControlFlowEscapeType.closureEscape,rethrowEscape, andconstructorInitializerEscape. - Signatures now propagate
await forasync-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.
- Added
0.2.1 #
- Broaden
analyzercompatibility to support versions12.xthrough14.x.
0.2.0 #
Scoring fixes aligning with the SonarSource Cognitive Complexity whitepaper (v1.7) and its reference implementation (sonar-java):
else ifchains no longer deepen nesting: branch contents sit one level below the headif(previously each chain link added an extra level).switchstatements/expressions andcatchclauses 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/setprefix, matching class members. --fail-on-increaseno longer flags newly added declarations (they have no baseline); they are governed by--fail-thresholdalone.- Directory exclusion (
.git,.dart_tool,build) now matches whole path segments, so.github/and similar directories are scanned correctly.
0.1.0 #
- Initial version.