name: code-complexity-analyzer description: 分析代码复杂度指标,包括圈复杂度、代码异味和技术债务 allowed-tools:
- Bash
- Read
- Write
- Glob
- Grep
代码复杂度分析器技能
概述
分析代码复杂度指标,包括圈复杂度、认知复杂度、代码异味、重复代码检测和技术债务评分。
能力
- 计算圈复杂度
- 计算认知复杂度
- 识别代码异味
- 依赖关系分析
- 重复代码检测
- 技术债务评分
- 可维护性指数计算
- 代码行数指标
目标流程
- 重构计划
- 性能优化
- 系统设计评审
输入模式
{
"type": "object",
"required": ["paths"],
"properties": {
"paths": {
"type": "array",
"items": { "type": "string" },
"description": "要分析的路径(支持通配符模式)"
},
"metrics": {
"type": "array",
"items": {
"type": "string",
"enum": ["cyclomatic", "cognitive", "loc", "dependencies", "duplicates", "maintainability"]
},
"default": ["cyclomatic", "cognitive", "loc"]
},
"thresholds": {
"type": "object",
"properties": {
"cyclomatic": { "type": "number", "default": 10 },
"cognitive": { "type": "number", "default": 15 },
"duplicateLines": { "type": "number", "default": 6 }
}
},
"languages": {
"type": "array",
"items": { "type": "string" },
"description": "要分析的语言"
}
}
}
输出模式
{
"type": "object",
"properties": {
"files": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": { "type": "string" },
"metrics": {
"type": "object",
"properties": {
"cyclomatic": { "type": "number" },
"cognitive": { "type": "number" },
"loc": { "type": "number" },
"maintainability": { "type": "number" }
}
},
"violations": { "type": "array" }
}
}
},
"summary": {
"type": "object",
"properties": {
"totalFiles": { "type": "number" },
"averageComplexity": { "type": "number" },
"technicalDebtScore": { "type": "number" },
"hotspots": { "type": "array" }
}
},
"duplicates": {
"type": "array"
}
}
}
使用示例
{
kind: 'skill',
skill: {
name: 'code-complexity-analyzer',
context: {
paths: ['src/**/*.ts'],
metrics: ['cyclomatic', 'cognitive', 'loc', 'dependencies'],
thresholds: { cyclomatic: 10, cognitive: 15 }
}
}
}