Skip to content

v3.4.0

Choose a tag to compare

@gbrandtio gbrandtio released this 12 Jul 09:28
  • FEAT (Metrics): Added a shared NestingResolver that computes control-flow nesting depth per token in a single pass, with per-language strategies declared via a new BlockStructure on LanguageProfile: 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 via lexical_metrics.dart. See ADR-0018.
  • BREAKING (Metrics): Rewrote CognitiveComplexityAlgorithm against the SonarSource specification on top of resolved depths. Function bodies, argument lists, and literals no longer count as nesting; else/elif score a flat +1 with else if collapsed to one increment; switch counts once and case arms do not; ternary ? counts (disambiguated from nullable-type markers) and ?? scores +1; C preprocessor #if is 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): IndentationComplexityAlgorithm now 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): FsmLexer stamps 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 from controlFlowKeywords (they lex as operators and could never match identifier lookups); added lambdaIntroducers (=>, ->) and keyword-end block vocabularies to the default profiles.
  • BREAKING (Metrics): Rewrote NpathComplexityAlgorithm to utilize NestingResolver to 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): AbcScoreAlgorithm now 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

Full Changelog: v3.3.2...v3.4.0