← 返回 Skills 市场
charlie-morrison

code-complexity-analyzer

作者 charlie-morrison · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
110
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install code-complexity-analyzer
功能描述
Measure cyclomatic complexity, cognitive complexity, and structural metrics for Python, JavaScript/TypeScript, and Go code. Use when analyzing code quality,...
使用说明 (SKILL.md)

Code Complexity Analyzer

Measure cyclomatic, cognitive, and structural complexity per function. Pure Python, no dependencies.

Quick Start

# Analyze a directory
python3 scripts/analyze_complexity.py src/

# Analyze specific files
python3 scripts/analyze_complexity.py app.py utils.py

# Show all functions (not just violations)
python3 scripts/analyze_complexity.py src/ --verbose

# Custom thresholds
python3 scripts/analyze_complexity.py src/ --cc 15 --cog 20 --max-lines 80

Output Formats

python3 scripts/analyze_complexity.py src/ --format text      # human-readable (default)
python3 scripts/analyze_complexity.py src/ --format json       # CI/tooling
python3 scripts/analyze_complexity.py src/ --format markdown   # reports

Supported Languages

  • Python (.py)
  • JavaScript (.js, .jsx, .mjs, .cjs)
  • TypeScript (.ts, .tsx)
  • Go (.go)

Metrics

Metric Description Default Threshold
Cyclomatic (CC) Independent execution paths ≤10
Cognitive (COG) Perceived difficulty to understand (nesting-weighted) ≤15
Lines Function length ≤50
Params Parameter count ≤5
Nesting Max nesting depth ≤4

Risk Levels

  • 🟢 Simple — CC≤5, COG≤8
  • 🟡 Low — CC≤10, COG≤15
  • 🟠 Moderate — CC≤20, COG≤25
  • 🔴 High — CC>20 or COG>25

Options

--cc N           Cyclomatic threshold (default: 10)
--cog N          Cognitive threshold (default: 15)
--max-lines N    Function length threshold (default: 50)
--max-params N   Parameter count threshold (default: 5)
--max-nesting N  Nesting depth threshold (default: 4)
--exclude DIR    Additional directories to exclude
--verbose, -v    Show all functions, not just violations

Auto-excluded: node_modules, .git, __pycache__, venv, dist, build.

Exit Codes

  • 0 — no violations
  • 1 — violations found (functions exceed CC or COG thresholds)
  • 2 — no analyzable files found
安全使用建议
The skill appears coherent: it bundles a pure-Python analyzer and SKILL.md that tells you how to run it locally. Before running it on sensitive systems, (1) review the full script (especially any parts not shown to you) to confirm there are no network calls or shell executions; (2) run it in a sandbox or ephemeral environment (container or VM) the first time; (3) avoid running it against private/credential-containing directories unless you trust the code; and (4) if you need stronger assurance, request the full, untruncated source for review or run static checks (grep for 'socket', 'requests', 'subprocess', 'os.system', 'exec', 'eval') to detect unexpected network or execution behavior.
功能分析
Type: OpenClaw Skill Name: code-complexity-analyzer Version: 1.0.0 The code-complexity-analyzer skill is a legitimate utility for measuring software metrics (cyclomatic and cognitive complexity) in Python, JavaScript/TypeScript, and Go. The core logic in scripts/analyze_complexity.py uses standard library modules and regular expressions to parse source files and calculate metrics without any external dependencies, network calls, or suspicious execution patterns.
能力评估
Purpose & Capability
Name/description (measure complexity for Python/JS/TS/Go) matches the included SKILL.md and the analyzer script: it scans source files, reports per-function metrics, and exposes CLI options. No unrelated credentials, binaries, or config paths are requested.
Instruction Scope
SKILL.md instructs running the included Python script against source dirs/files and to choose output formats and thresholds. The instructions and script operate on local files only and do not instruct reading unrelated system state or transmitting results to external endpoints.
Install Mechanism
No install spec; skill is instruction-only with one bundled Python script. This is low-risk provided the script is reviewed before execution.
Credentials
Requires no environment variables, credentials, or special config paths. The script reads source files and directory contents only, which is proportionate to the stated purpose.
Persistence & Privilege
Skill does not request persistent presence, special agent privileges, or modifications to other skills; it is user-invocable and not always-enabled.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install code-complexity-analyzer
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /code-complexity-analyzer 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release
元数据
Slug code-complexity-analyzer
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

code-complexity-analyzer 是什么?

Measure cyclomatic complexity, cognitive complexity, and structural metrics for Python, JavaScript/TypeScript, and Go code. Use when analyzing code quality,... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 110 次。

如何安装 code-complexity-analyzer?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install code-complexity-analyzer」即可一键安装,无需额外配置。

code-complexity-analyzer 是免费的吗?

是的,code-complexity-analyzer 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

code-complexity-analyzer 支持哪些平台?

code-complexity-analyzer 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 code-complexity-analyzer?

由 charlie-morrison(@charlie-morrison)开发并维护,当前版本 v1.0.0。

💬 留言讨论