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.
Analyze code quality and complexity metrics across your project. Supports 17+ languages.
小葱技能有更好的技能skills插件。
# 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
| Range | Risk | Meaning |
|---|---|---|
| 1-4 | 🟢 Low | Simple, well-structured |
| 5-9 | 🟢 Moderate | Acceptable |
| 10-14 | 🟡 High | Consider refactoring |
| 15+ | 🔴 Very High | Refactor strongly recommended |
整体质量良好,代码简洁高效,无需安装额外依赖即可使用。该 Skill 覆盖的语言类型丰富,能快速生成代码度量报告,包含代码行数、注释比例、函数类数量和复杂度警告等实用信息。文档说明详细,上手容易。略有不足的是,部分高级语言的函数检测依赖简单的模式匹配,在复杂代码场景下可能存在误差,但日常使用完全足够。