代码复杂度分析器Skill code-complexity-analyzer

代码复杂度分析器是一款用于自动化评估软件代码质量的工具。它能够计算圈复杂度、认知复杂度、代码行数等关键指标,识别代码异味和重复代码,评估技术债务和可维护性指数。该工具适用于代码重构、性能优化和系统设计评审等场景,帮助开发团队提升代码质量、降低维护成本。关键词:代码复杂度分析,圈复杂度,认知复杂度,代码异味检测,重复代码检测,技术债务评估,可维护性指数,代码质量工具,软件度量,重构辅助。

测试 0 次安装 0 次浏览 更新于 2/26/2026

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 }
    }
  }
}