CtrlK
BlogDocsLog inGet started
Tessl Logo

verify-quality

代码质量校验关卡。检测复杂度、重复代码、命名规范、函数长度等质量指标。当用户提到代码质量、复杂度检查、代码异味、重构建议、lint检查、代码规范时使用。在复杂模块、重构完成时自动触发。

63

Quality

76%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Passed

No findings from the security scan

Fix and improve this skill with Tessl

tessl review fix ./dsh-ccg/skills/verify-quality/SKILL.md
SKILL.md
Quality
Evals
Security

⚖ 校验关卡 · 代码质量

核心原则

代码质量 = 可读性 + 可维护性 + 可测试性
劣质代码是技术债,技术债是道基裂痕
复杂度是 bug 的温床

自动检查

运行质量检查脚本(跨平台):

# 在 skill 目录下运行
node scripts/quality_checker.js <扫描路径>
node scripts/quality_checker.js <扫描路径> -v      # 详细模式
node scripts/quality_checker.js <扫描路径> --json  # JSON 输出

检测指标

复杂度指标

指标阈值超标后果
圈复杂度≤ 10🟠 警告,建议拆分
函数长度≤ 50 行🟠 警告,建议拆分
文件长度≤ 500 行🟡 提示,考虑拆分
参数数量≤ 5🟠 警告,考虑封装
嵌套深度≤ 4🟠 警告,建议重构
行长度≤ 120🔵 提示

命名规范

类型规范示例
类名PascalCaseUserService, HttpClient
函数名snake_caseget_user, process_data
常量UPPER_SNAKEMAX_RETRY, DEFAULT_TIMEOUT
变量snake_caseuser_id, total_count

代码异味

异味说明严重度
重复代码相似代码块 > 10 行🟠 High
过长参数列表参数 > 5 个🟡 Medium
魔法数字未命名的常量🟡 Medium
死代码未使用的函数/变量🔵 Low
注释代码被注释的代码块🔵 Low

自动触发时机

场景触发条件
复杂模块代码行数 > 200
重构完成重构任务完成时
代码审查PR/MR 审查时
提交前代码提交前检查

校验流程

1. 扫描代码文件
2. 计算复杂度指标
3. 检测代码异味
4. 验证命名规范
5. 输出质量校验报告

校验报告格式

## 代码质量校验报告

✓ 通过 | ✗ 未通过

### 复杂度指标
- 平均函数复杂度: N
- 超标函数数: N
- 最大文件行数: N

### 代码异味
- 🟠 High: N
- 🟡 Medium: N
- 🔵 Low: N

### 问题清单

| 文件 | 行号 | 类型 | 严重度 | 描述 |
|------|------|------|--------|------|
| ... | ... | ... | ... | ... |

### 结论
可交付 / 需重构后交付

重构建议

降低复杂度

# 🔴 高复杂度 - 道基不稳
def process(data):
    if condition1:
        if condition2:
            if condition3:
                # 深层嵌套
                pass

# ✅ 低复杂度 - 道基稳固
def process(data):
    if not condition1:
        return
    if not condition2:
        return
    if not condition3:
        return
    # 主逻辑

消除重复

# 🔴 重复代码 - 异端
def func1():
    # 10行相同逻辑
    pass

def func2():
    # 10行相同逻辑
    pass

# ✅ 提取公共函数 - 正道
def common_logic():
    # 公共逻辑
    pass

def func1():
    common_logic()

def func2():
    common_logic()

Repository
fengshao1227/ccg-workflow
Last updated
First committed

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.