plan-lower-code-complexity

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Lower Code Complexity

降低代码复杂度

Reduces the cognitive complexity threshold by 2 and fixes all violations.
将认知复杂度阈值降低2并修复所有违规问题。

Step 1: Gather Requirements

步骤1:收集需求

  1. Read current threshold from eslint config (cognitive-complexity rule)
  2. Calculate new threshold: current - 2 (e.g., 15 -> 13)
  3. Run lint with the new threshold to find violations:
    bash
    bun run lint 2>&1 | grep "cognitive-complexity"
  4. Note for each violation:
    • File path and line number
    • Function name
    • Current complexity score
If no violations at new threshold, report success and exit.
  1. 从eslint配置(cognitive-complexity规则)中读取当前阈值
  2. 计算新阈值:当前值 - 2(例如:15 → 13)
  3. 使用新阈值运行lint以查找违规问题:
    bash
    bun run lint 2>&1 | grep "cognitive-complexity"
  4. 记录每个违规信息
    • 文件路径和行号
    • 函数名称
    • 当前复杂度得分
如果在新阈值下没有违规问题,报告成功并退出。

Step 2: Compile Brief and Delegate

步骤2:编写摘要并分配任务

Compile the gathered information into a structured brief:
Reduce cognitive complexity threshold from [current] to [new].

Functions exceeding threshold (ordered by complexity):
1. [file:function] (complexity: X, target: [new]) - Line Y
2. ...

Configuration change: [eslint config path], cognitive-complexity from [current] to [new]

Refactoring strategies: extract functions, early returns, extract conditions, use lookup tables

Verification: `bun run lint 2>&1 | grep "cognitive-complexity" | wc -l` → Expected: 0
Invoke
/plan-create
with this brief to create the implementation plan.
将收集到的信息整理为结构化摘要:
Reduce cognitive complexity threshold from [current] to [new].

Functions exceeding threshold (ordered by complexity):
1. [file:function] (complexity: X, target: [new]) - Line Y
2. ...

Configuration change: [eslint config path], cognitive-complexity from [current] to [new]

Refactoring strategies: extract functions, early returns, extract conditions, use lookup tables

Verification: `bun run lint 2>&1 | grep "cognitive-complexity" | wc -l` → Expected: 0
调用
/plan-create
,使用此摘要创建实施计划。