code-metrics-analyzer

paleoterra's avatarfrom paleoterra

Calculate code quality metrics - complexity, coverage, maintainability

⭐1stars🔀0forks📁View on GitHub🕐Updated Nov 25, 2025

When & Why to Use This Skill

The Code Metrics Analyzer is a comprehensive Claude skill designed to evaluate software health by calculating key performance indicators such as cyclomatic complexity, code coverage, and maintainability index. It helps developers identify technical debt, locate overly complex methods, and generate detailed quality reports to ensure long-term project sustainability and code readability.

Use Cases

  • Technical Debt Assessment: Identify high-complexity functions and 'god objects' that require refactoring to reduce maintenance costs.
  • Automated Quality Audits: Generate detailed reports on LOC, comment density, and inheritance depth to ensure the codebase meets organizational standards.
  • Pre-merge Code Evaluation: Use as a gatekeeping tool during code reviews to flag methods that exceed complexity thresholds before they are merged.
  • Test Coverage Analysis: Pinpoint critical areas of the application that lack sufficient test coverage to prioritize QA and testing efforts.
namecode-metrics-analyzer
descriptionCalculate code quality metrics - complexity, coverage, maintainability
typeskill
languagepython

Code Metrics Analyzer

Measure code quality through various metrics.

Capabilities

  • Calculate cyclomatic complexity
  • Measure code coverage
  • Analyze lines of code (LOC)
  • Count methods/functions per file
  • Measure comment density
  • Identify complex methods
  • Track metrics over time
  • Generate quality reports
  • Find refactoring candidates

Tools

code_metrics.py - Calculate various code metrics

Metrics Calculated

  • Cyclomatic Complexity - Decision point count
  • Cognitive Complexity - Mental effort to understand
  • LOC - Lines of code (total, code, comments, blank)
  • Method Count - Methods per class/file
  • Depth of Inheritance - Class hierarchy depth
  • Comment Ratio - Comments vs code
  • Test Coverage - Percentage tested

Commands

# Analyze project
./code_metrics.py analyze --source-dir PaleoRose

# Find complex methods
./code_metrics.py complex --threshold 10

# Generate report
./code_metrics.py report --format html

Output

Code Metrics Summary
====================
Total Files: 104
Total LOC: 15,234
Average Complexity: 4.2

Most Complex Files:
1. XRoseTableController.m (complexity: 28)
2. InMemoryStore.swift (complexity: 22)
3. DocumentModel.swift (complexity: 18)

Refactoring Candidates:
- XRoseTableController.configureController (complexity: 15)
- InMemoryStore.readFromStore (complexity: 12)