Moyu Linter Moyu Linter

GitHub Action:自动检测 PR 中的过度工程信号。零依赖,即插即用。 A GitHub Action that detects over-engineering signals in your pull requests. Zero dependencies.

快速配置 Quick Setup

创建 .github/workflows/moyu-lint.yml Create .github/workflows/moyu-lint.yml:

name: Moyu Lint on: pull_request: types: [opened, synchronize] jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: uucz/moyu/linter@main with: github-token: ${{ secrets.GITHUB_TOKEN }}

6 个检测信号 6 Detection Signals

不必要的文档字符串Unnecessary Docstrings

检测为已有函数添加的 docstring / JSDoc,而非新函数。Docstrings added to existing functions, not new ones.

过度错误处理Excessive Error Handling

新增代码中 try/catch/except 占比过高(>20%)。High ratio of try/catch/except in added code (>20%).

未请求的新文件New Files Created

PR 中创建了全新文件,可能超出需求范围。Entirely new files that may exceed the requested scope.

类型检查膨胀Type-Check Bloat

过多的 isinstance / typeof / type() 检查。Excessive isinstance / typeof / type() checks.

不必要的抽象Unnecessary Abstractions

新增 class / interface / 设计模式命名(Factory、Strategy 等)。New class/interface declarations or design pattern names (Factory, Strategy, etc).

范围蔓延Scope Creep

变更文件数远超 PR 标题/描述所涉及的范围。Many files changed relative to PR title/description scope.

评分指南 Score Guide

分数Score 等级Grade 含义Meaning
0🐟 Perfect无过度工程信号No over-engineering detected
1-3🐠 Minor少量信号,通常没问题A few signals, probably fine
4-6🐠 Moderate建议简化Consider simplifying
7+🐡 HighPR 可能过度工程PR may be over-engineered

示例报告 Sample Report

🐡 Moyu Lint Report

Score: 10 — High — this PR may be over-engineered

SignalScoreDetails
New files created1task_factory.py: new file (+30 lines)
Type-check bloat1task_factory.py: 3 type-checking lines added
Unnecessary abstractions8task_factory.py: 4 new class declarations
Moyu says: The best code is the code you didn't write.

本地使用 (CLI) Local Usage (CLI)

# Lint last commit node linter/index.mjs # Lint specific range node linter/index.mjs HEAD~3 # Lint from stdin git diff main...HEAD | node linter/index.mjs --stdin # Set failure threshold node linter/index.mjs --threshold=5