Commit b97af8c
committed
feat: halstead metrics and maintainability index for code health scoring
Add formal code health metrics per function: Halstead volume, difficulty,
effort, bugs estimate, LOC/SLOC, and the industry-standard Maintainability
Index (MI) normalized to 0-100 (Microsoft convention). MI below 20 flags
functions needing refactoring attention.
- DB migration v9: 14 new columns on function_complexity table
- HALSTEAD_RULES registry for JS/TS/TSX operator/operand classification
- computeHalsteadMetrics(), computeLOCMetrics(), computeMaintainabilityIndex()
- complexity command: MI column in default view, --health flag for full
Halstead view, --sort mi|volume|effort|bugs|loc options
- stats/context/explain commands surface MI per function
- MCP tool schema updated with new sort values and health property
- Config: maintainabilityIndex threshold { warn: 20, fail: null }
- 29 new tests (18 unit + 11 integration)
Impact: 16 functions changed, 30 affected
Impact: 16 functions changed, 30 affected1 parent 5a7d039 commit b97af8c
9 files changed
Lines changed: 786 additions & 38 deletions
File tree
- src
- tests
- integration
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
717 | | - | |
| 717 | + | |
718 | 718 | | |
719 | 719 | | |
720 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
721 | 725 | | |
| 726 | + | |
722 | 727 | | |
723 | 728 | | |
724 | 729 | | |
| |||
735 | 740 | | |
736 | 741 | | |
737 | 742 | | |
| 743 | + | |
738 | 744 | | |
739 | 745 | | |
740 | 746 | | |
| |||
0 commit comments