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

  • 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

🔥 大家都在搜

wps 写作 pdf 苹果