From c9b37be9f0da9720625dd53e7dc0dd46ca4108d2 Mon Sep 17 00:00:00 2001 From: furedea <132188853+furedea@users.noreply.github.com> Date: Sun, 18 Oct 2026 18:19:33 +0900 Subject: [PATCH] build(lint): enforce the AGENTS.md size and complexity rules Cap arguments, nesting, and cognitive complexity through clippy, require reasons on allow attributes, and reject staged Rust files longer than 500 lines in pre-commit. Refs furedea/dotfiles#213 Co-Authored-By: Claude Opus 5.5 --- Cargo.toml | 3 +++ clippy.toml | 3 +++ lefthook.yml | 8 ++++++++ 3 files changed, 14 insertions(+) create mode 100644 clippy.toml diff --git a/Cargo.toml b/Cargo.toml index ac621fe..6004a36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,3 +9,6 @@ license = "MIT" [lints.clippy] all = { level = "warn", priority = -1 } pedantic = { level = "warn", priority = -1 } +allow_attributes_without_reason = "warn" +cognitive_complexity = "warn" +excessive_nesting = "warn" diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000..a1a18f9 --- /dev/null +++ b/clippy.toml @@ -0,0 +1,3 @@ +too-many-arguments-threshold = 3 +excessive-nesting-threshold = 2 +cognitive-complexity-threshold = 15 diff --git a/lefthook.yml b/lefthook.yml index 395b7ca..d9f30a1 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -23,3 +23,11 @@ pre-commit: run: cargo clippy -- -D warnings ls-lint: run: ls_lint + file-length: + glob: "*.rs" + run: | + for f in {staged_files}; do + n=$(wc -l < "$f") + [ "$n" -le 500 ] || { echo "$f: $n lines (max 500)"; fail=1; } + done + exit ${fail:-0}