From e86510489f4c6be4426555b14f1d95d5a27cd3b2 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 9 Nov 2026 19:50:40 -0700 Subject: [PATCH] fix(scripts): the raw-arithmetic detector reads a package with no library `scripts/raw-decimal-arith.sh ledger-cli` stopped with cargo's error ("no library targets found"): the script asked clippy for `--lib`, and ledger-cli is its programs alone. It now asks for the library and the programs where there is a library, and the programs where there is not. With that the count of money arithmetic outside the kernel is complete for the outer crates: ledger-gui 137, ledger-import 22, ledger-mcp 19, ledger-package 13, ledger-store 8, ledger-config 2, and none in ledger-cli, ledger-host, ledger-reader and ledger-vault. Co-Authored-By: Claude --- scripts/raw-decimal-arith.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/raw-decimal-arith.sh b/scripts/raw-decimal-arith.sh index e69e1d31..72c4bb09 100755 --- a/scripts/raw-decimal-arith.sh +++ b/scripts/raw-decimal-arith.sh @@ -72,10 +72,15 @@ printf 'disallowed-methods = [%s]\n' "$methods" > "$work/all/clippy.toml" printf 'arithmetic-side-effects-allowed = ["rust_decimal::Decimal", "rust_decimal::decimal::Decimal"]\n' } > "$work/rest/clippy.toml" +# The library and the programs: a package with no library (ledger-cli) is +# its programs alone, and cargo refuses `--lib` there. +targets=(--bins) +if [ -f "crates/$pkg/src/lib.rs" ]; then targets=(--lib --bins); fi + # One clippy run: the findings as `filelinecolumnlintwhatsource`. run() { local name=$1 status=0 - CLIPPY_CONF_DIR="$work/$name" cargo clippy --quiet -p "$pkg" --lib \ + CLIPPY_CONF_DIR="$work/$name" cargo clippy --quiet -p "$pkg" "${targets[@]}" \ --target-dir "target/raw-arith/$name" --message-format=json -- \ -A clippy::all -W clippy::arithmetic_side_effects -W clippy::disallowed_methods \ > "$work/$name.json" 2> "$work/$name.err" || status=$?