@aj-geddes/code-metrics-analysis

>

View in AI SkillSafe app
Scanned · no findings
0 downloads
0 stars
0 demos
SKILL.md
namecode-metrics-analysis
description>

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:

Guide Contents
TypeScript Complexity Analyzer TypeScript Complexity Analyzer
Python Code Metrics (using radon) Python Code Metrics (using radon)
ESLint Plugin for Complexity ESLint Plugin for Complexity
CI/CD Quality Gates CI/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

Embed badges

Add these to your README to show the skill's verification status.

SkillSafe verified badge
Verified badge
[![SkillSafe verified badge](https://api.skillsafe.ai/v1/badge/@aj-geddes/code-metrics-analysis/verified)](https://skillsafe.ai/skill/@aj-geddes/code-metrics-analysis/)
Installs badge
Installs badge
[![Installs badge](https://api.skillsafe.ai/v1/badge/@aj-geddes/code-metrics-analysis/installs)](https://skillsafe.ai/skill/@aj-geddes/code-metrics-analysis/)
Scan badge
Scan badge
[![Scan badge](https://api.skillsafe.ai/v1/badge/@aj-geddes/code-metrics-analysis/scan)](https://skillsafe.ai/skill/@aj-geddes/code-metrics-analysis/)
Eval pass rate badge
Eval pass rate
[![Eval pass rate badge](https://api.skillsafe.ai/v1/badge/@aj-geddes/code-metrics-analysis/eval)](https://skillsafe.ai/skill/@aj-geddes/code-metrics-analysis/)