1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Clippy thresholds for knot.
#
# Counts below were measured on production code (excluding `*/tests.rs`,
# `tests/` and `benches/`) with `cargo clippy --all-targets --all-features`
# on clippy 0.1.97.
#
# NOTE: a threshold here does NOT enable a lint, it only parametrizes it.
# The lint's default level decides whether it fires:
#
# too_many_arguments complexity warn -> active out-of-the-box
# type_complexity complexity warn -> active out of the box
# excessive_nesting complexity warn -> active once threshold > 0
# too_many_lines pedantic allow -> needs [lints.clippy]
# cognitive_complexity nursery allow -> needs [lints.clippy]
#
# The last two are enabled in Cargo.toml's [lints.clippy] section.
# --- Active by default (complexity group) ---
# clippy::too_many_arguments (default: 7)
# Measured curve: 4 -> 45 | 5 -> 19 | 6 -> 6 | 7 -> 0
# The repo's real maximum is 7, so the distribution is narrow. 4 is
# disproportionate, 6 barely helps. 5 is the useful point.
= 5
# clippy::type_complexity (default: 250)
# Measured curve: 150 -> 10 | 200 -> 1 | 250 -> 0
# 200 costs a single violation and already improves on the default.
# Later target: 150.
= 200
# clippy::excessive_nesting (default: 0, which disables the lint)
# The lint is warn-by-default; the zero threshold is what silences it,
# so setting a value here activates it without touching Cargo.toml.
# Measured curve: 3 -> 519 | 4 -> 220 | 5 -> 77 | 6 -> 26
# 6 is the only manageable entry point. Later target: 5.
= 6
# --- Enabled via [lints.clippy] in Cargo.toml ---
# clippy::too_many_lines (pedantic, default: 100)
# Measured curve: 50 -> 97 | 60 -> 67 | 80 -> 42 | 100 -> 26 | 150 -> 12
# Median function length: 71 lines. Worst offender: 448 lines.
# 50 would mean 97 refactors at once; enter at 80 and tighten in steps.
= 80
# clippy::cognitive_complexity (nursery, default: 25)
# The lint runs post-macro-expansion; each tracing:: macro call adds ~8 points,
# so log-dense code scores high with no real branching. Empirical model:
#
# score ≈ 1 + branches + 8 × (tracing:: calls)
#
# Validated on 5+ functions (r²≈1). Practical implication: the threshold of 40
# is roughly "≤4 tracing:: calls per function". Measured distribution at
# threshold 25 (post-0.4.1 refactor, excluding tests):
# cleanup.rs:delete_repo_from_databases 28 | local_sync.rs:copy_file_child 32
# worker/mod.rs:acquire_lock_or_requeue 31 | worker/mod.rs:log_state_source 30
# worker/mod.rs:claim_queued_job 28 | main.rs:setup_neo4j 35 (max)
# Gap [36, 39] is empty. 40 is the stable entry point: lowering to 35 would
# flag setup_neo4j (22 lines, 2 retry loops — macro noise, not complexity),
# and lowering to 28 would catch delete_repo_from_databases (17 lines, 3
# independent if-let-Err blocks). Do NOT read 40 as permission to write
# complex functions; read it as the point where the metric stops being noise.
= 40