Skip to content

Dart: cyclomatic complexity skips 'on T' handlers without a catch clause #24

Closed

Description

@ElbertePlinio

Found while pinning the cognitive complexity rules for #7.

dart_decision counts only catch_clause. In tree-sitter-dart 0.2.0 an on T { ... } handler with no catch (e) has no catch_clause node: the try_statement holds a type and a block directly. Those handlers add nothing today.

void f(){ try { g(); } on StateError { h(); } on FormatException catch (e) { h(); } }

With limits.complexity: 1 pickcheck 0.3.0 reports complexity 2 > 1; the spec's rule (every catch clause adds 1) gives 3.

Fix: count each handler block child of try_statement other than its body field, which is the rule the cognitive spec in #7 uses. Needs a Dart golden fixture with an on T {} handler.

Activity

  1. added
    bug
    on Sep 27, 2026
  2. added a commit that references this issue on Sep 28, 2026
    469116c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions