mcpField
C
code-metrics-analysis

code-metrics-analysis

github.com/aj-geddesTesting & quality373458 installsUpdated 34w ago
Repository

About code-metrics-analysis

A skill for measuring and analyzing code quality metrics to help developers find complexity and maintainability issues. It includes guidance for TypeScript, Python, ESLint, and CI/CD quality gates.

Key features

  1. 01Analyze cyclomatic and cognitive complexity
  2. 02Track lines of code and function counts
  3. 03Guides for TypeScript and Python
  4. 04Apply metrics in CI/CD quality gates

Use cases

  1. 01Assess code quality and track technical debt
  2. 02Identify candidates for refactoring
  3. 03Use metrics during code reviews
  4. 04Set quality gates in CI/CD

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill code-metrics-analysis

After installing, type/code-metrics-analysisin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
cicd-quality-gates.md
eslint-plugin-for-complexity.md
python-code-metrics-using-radon.md
typescript-complexity-analyzer.md
scripts/
scaffold-tests.sh
templates/
test-template.js

Details

From the project README

Code Metrics Analysis

Table of Contents

Overview

Measure and analyze code quality metrics to identify complexity, maintainability issues, and areas for improvement.

When to Use

  • Code quality assessment
  • Identifying refactoring candidates
  • Technical debt monitoring
  • Code review automation
  • CI/CD quality gates
  • Team performance tracking
  • Legacy code analysis

Quick Start

Minimal working example:

import * as ts from "typescript";
import * as fs from "fs";

interface ComplexityMetrics {
  cyclomaticComplexity: number;
  cognitiveComplexity: number;
  linesOfCode: number;
  functionCount: number;
  classCount: number;
  maxNestingDepth: number;
}

class CodeMetricsAnalyzer {
  analyzeFile(filePath: string): ComplexityMetrics {
    const sourceCode = fs.readFileSync(filePath, "utf-8");
    const sourceFile = ts.createSourceFile(
      filePath,
      sourceCode,
      ts.ScriptTarget.Latest,
      true,
    );

    const metrics: ComplexityMetrics = {
      cyclomaticComplexity: 0,
      cognitiveComplexity: 0,
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
TypeScript Complexity AnalyzerTypeScript Complexity Analyzer
Python Code Metrics (using radon)Python Code Metrics (using radon)
ESLint Plugin for ComplexityESLint Plugin for Complexity
CI/CD Quality GatesCI/CD Quality Gates

Best Practices

✅ DO
  • Monitor metrics over time
  • Set reasonable thresholds
  • Focus on trends, not absolute numbers
  • Automate metric collection
  • Use metrics to guide refactoring
  • Combine multiple metrics
  • Include metrics in code reviews
❌ DON'T
  • Use metrics as sole quality indicator
  • Set unrealistic thresholds
  • Ignore context and domain
  • Punish developers for metrics
  • Focus only on one metric
  • Skip documentation

Comments

Markdown supported