Skip to content

feat(mirror): implement AST-based cyclomatic complexity checker in co…#439

Open
borjamoskv wants to merge 1 commit into
mainfrom
borjamoskv-patch-5
Open

feat(mirror): implement AST-based cyclomatic complexity checker in co…#439
borjamoskv wants to merge 1 commit into
mainfrom
borjamoskv-patch-5

Conversation

@borjamoskv

Copy link
Copy Markdown
Owner

Summary

Implements the TODO at cortex-core/mirror_audit.py line 59:

# TODO: Add cyclomatic complexity check in v6.5

Creates cortex/audit/mirror_audit.py with a full AST-based cyclomatic complexity checker.

What's included

  • measure_cyclomatic_complexity(node) — pure-AST McCabe scorer (If/For/While/ExceptHandler/With/Assert/comprehension/BoolOp/IfExp/Match)
  • scan_file(path) — iterator that yields ComplexityResult per function; graceful on SyntaxError/OSError
  • run_complexity_audit(root, ...) — recursive .py scanner with configurable thresholds and exclude-dirs
  • ComplexityStatus (PASS/WARN/FAIL), ComplexityResult, ComplexityReport dataclasses
  • CLI entry-point: python -m cortex.audit.mirror_audit [root]

Thresholds

Range Status
≤ 10 PASS
11–20 WARN
> 20 FAIL

All output goes through logging — zero bare print() calls in production paths.

Closes #396

…rtex/audit/mirror_audit.py

This implementation introduces a cyclomatic complexity checker for Python functions in the CORTEX project, measuring and reporting complexity based on defined thresholds.
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

∞ MÖBIUS — PR Analysis

Metric Value
Files changed 1
Total changes 283 (+/-)
Complexity high
Est. review time 30 min
Has tests? ⚠️ Missing
Has Rust changes? No

Labels applied:

Warning

No test files detected in this PR. Consider adding tests.


Generated by MÖBIUS (Clojure/Babashka) — where code IS data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mirror): implement cyclomatic complexity check in mirror_audit.py

1 participant