← 全部工具

mukundzha/scrut

热度 65 更新于 开发与构建

Review your code before it leaves your machine.

githubauto-collected

安装

暂未验证可直接使用的安装命令,请查看项目官方文档或 Release。

Scrut

AST-based static analysis for unstaged Python changes.

---

Table of Contents

  • What is Scrut?
  • Why AST?
  • Features
  • Architecture
  • Repository Layout
  • Installation
  • Quick Start
  • Example Output
  • Review Rules
  • Data Model
  • Exit Behavior
  • Current Limitations
  • Roadmap
  • Contributing
  • License

---

What is Scrut?

Scrut is a CLI tool that analyzes unstaged changes in Git repositories. It parses changed Python files with ast.parse, checks four structural rules, and prints a formatted report — zero dependencies beyond Python 3.10+ and Git.

No configuration files. No plugins. No network access.

It is for Python developers who want lightweight, offline feedback on code structure before opening a pull request.

---

Why AST?

Most review tools use regex to detect code issues. Regex cannot reliably match multi-line function signatures, measure nesting depth, or distinguish definitions from calls.

Python's ast module parses source into a syntax tree. From the tree, Scrut reads:

  • Parameter count — len(node.args.args)
  • Nesting depth — recursive walk counting only For, If, and While nodes
  • Line counts — endlineno - lineno

The tree structure guarantees correct results for every valid Python file. There are no false positives from comment strings, no missed multi-line signatures, no fragile patterns.