v3.4.0
- FEAT (Metrics): Added a shared
NestingResolverthat computes control-flow nesting depth per token in a single pass, with per-language strategies declared via a newBlockStructureonLanguageProfile: brace-delimited (control/lambda/neutral frame classification), indentation-based (indent/dedent synthesis from newline indent stamps, with bracket-continuation handling), and keyword-terminated (end/fi/done, with statement-position filtering of Ruby/Lua modifier forms). Exported vialexical_metrics.dart. See ADR-0018. - BREAKING (Metrics): Rewrote
CognitiveComplexityAlgorithmagainst the SonarSource specification on top of resolved depths. Function bodies, argument lists, and literals no longer count as nesting;else/elifscore a flat +1 withelse ifcollapsed to one increment;switchcounts once andcasearms do not; ternary?counts (disambiguated from nullable-type markers) and??scores +1; C preprocessor#ifis ignored. Python nesting is now visible (previously the metric degenerated to cyclomatic counting for indentation languages). Scores are not comparable with pre-3.4.0 values. - BREAKING (Metrics):
IndentationComplexityAlgorithmnow reports genuine control-flow nesting from the shared resolver instead of raw brace counting, and returns consistent keys (max_nesting_depth,average_nesting_depth) for empty input. - Improvement (Lexer):
FsmLexerstamps each newline token with the indentation width of the line it opens (Token.indentWidth; tabs expand to the next multiple of 8, blank/comment-only lines stamp -1), preserving the structural whitespace signal for indentation-based languages without emitting whitespace tokens. - FIX (Profiles): Removed dead
'?'/'??'entries fromcontrolFlowKeywords(they lex as operators and could never match identifier lookups); addedlambdaIntroducers(=>,->) and keyword-end block vocabularies to the default profiles. - BREAKING (Metrics): Rewrote
NpathComplexityAlgorithmto utilizeNestingResolverto accurately compute acyclic paths across depths using a stack-based model, correctly differentiating between multiplicative paths (sequential decisions) and additive paths (nested decisions). - FIX (Metrics):
AbcScoreAlgorithmnow correctly classifies function and method calls as Branches (B) via token lookahead, and control-flow/logical operators as Conditions (C), perfectly aligning with the Fitzpatrick (1997) ABC metric specification. - DOCS (ADRs): Updated ADR-0018 to confirm Cyclomatic Complexity deliberately excludes depth factors, and removed a forward-looking promise regarding future algorithm adoptions.
What's Changed
- Create agnostic-code-metrics.yml by @gbrandtio in #11
Full Changelog: v3.3.2...v3.4.0