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 <noreply@anthropic.com>
This commit is contained in:
1 parent
b66dff899d
commit
e86510489f
1 file changed
+6
-1
@@ -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 `file<TAB>line<TAB>column<TAB>lint<TAB>what<TAB>source`.
|
||||
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=$?
|
||||
|
||||
Reference in new issue
Block a user