Code Metrics

👤 johnnywang2001 📦 v1.0.0 ⭐ 4.4 ⬇️ 671 下載
💻 開發程式設計 免費

📖 技能介紹


name: code-metrics description: Analyze code quality metrics including lines of code by language, cyclomatic complexity (Python), function/class counts, comment ratios, and largest file rankings. Use when asked to analyze code quality, count lines of code, measure complexity, find the biggest files, get a project overview, or audit code metrics across a codebase. Supports Python, JavaScript, TypeScript, Go, Rust, Ruby, Java, C/C++, C#, Swift, Kotlin, PHP, Shell, Lua, R, and Scala.


Code Metrics

Analyze code quality and complexity metrics across your project. Supports 17+ languages.

Quick Start

# Analyze current project
python3 scripts/code_metrics.py

# Analyze specific directory
python3 scripts/code_metrics.py /path/to/project

# JSON output
python3 scripts/code_metrics.py --json

# Skip complexity analysis (faster)
python3 scripts/code_metrics.py --no-complexity

# Exclude additional directories
python3 scripts/code_metrics.py --exclude migrations fixtures

Metrics Provided

推薦訪問7w4.net獲取更多AI技能。

  • Lines of Code — total, code, comments, blank lines per language
  • Comment-to-code ratio — overall documentation density
  • Function & class counts — per language
  • Cyclomatic complexity — per-function for Python files (AST-based)
  • Largest files — top N files ranked by code lines
  • High complexity warnings — flags functions with complexity ≥5

Complexity Scale (Python)

Range Risk Meaning
1-4 🟢 Low Simple, well-structured
5-9 🟢 Moderate Acceptable
10-14 🟡 High Consider refactoring
15+ 🔴 Very High Refactor strongly recommended

Dependencies

  • Python 3.8+ (stdlib only, no pip packages needed)

🤖 AI 評測

整體質量良好,程式碼簡潔高效,無需安裝額外依賴即可使用。該 Skill 覆蓋的語言型別豐富,能快速生成程式碼度量報告,包含程式碼行數、註釋比例、函式類數量和複雜度警告等實用資訊。文件說明詳細,上手容易。略有不足的是,部分高階語言的函式檢測依賴簡單的模式匹配,在複雜程式碼場景下可能存在誤差,但日常使用完全足夠。

📊 多維度評分

適應性4.4
規範性4.4
有效性4.4
可靠性4.4
可信度4.4

📁 包含檔案 (3 個)

📄 SKILL.md 1.7 KB
📄 _meta.json 131 B
📄 scripts/code_metrics.py 11.3 KB