Repository navigation
ci(lint): add ML_PAT_A multi-line variant for weak >= N count assertions - #1013
Merged
Merged
Conversation
…tions Closes #1011. ## What `scripts/check-plugin-test-quality.sh` had multi-line variants for shapes B (`assert_ne!`), C (`!is_empty()`), and D (`!= 0`) added in #1005. Shape A — `assert!(x.len() >= N)` / precomputed-count — only had its single-line PAT_A. So a multi-line write of the original #992 bug shape: assert!( txn_count >= 3, "forecast should expand to at least 3 transactions" ); slipped past the lint. PR #1008 caught one such instance by hand; PR #1012 caught two more. ## Fix Added `ML_PAT_A` mirroring single-line `PAT_A` with the same count-shaped LHS restriction (`COUNT_LHS`) and the negative lookbehind for `prop_assert!`/`debug_assert!` that the other multi-line patterns already use: ML_PAT_A='(?<!\w)assert!\(\s*'"$COUNT_LHS"'\s*(?:>|>=)\s*\d+' Wired into the existing `find_multiline_in_rs` call. ## Knock-on: tightened one existing test The new pattern caught a real instance in `test_check_drained_adds_balance_assertions_on_close`: assert!( balance_count > 0, "should insert balance assertions after close" ); The plugin emits exactly one balance assertion per (closed account, currency); test setup has one Close on Assets:Bank with USD only, so we expect 1. Tightened to `assert_eq!(.count(), 1, ...)`. ## Self-test Extended `scripts/test-plugin-test-quality.sh` with 4 new cases (28 → 32 total): - multi-line `assert!(\n x.len() >= 1,\n "msg"\n)` - multi-line `assert!(\n price_count >= 1\n)` (the actual #992 shape) - multi-line `assert!(\n x.count() > 0\n)` - false-positive guard: multi-line `prop_assert!(\n x.len() >= 1\n)` must NOT fire ## Verified - 143/143 plugin tests pass (one pre-existing test tightened, no new test functions) - `scripts/check-plugin-test-quality.sh`: OK (clean on current main) - `scripts/test-plugin-test-quality.sh`: 32/32 - `cargo clippy -p rustledger-plugin --all-features --all-targets`: clean Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR closes a lint gap in the plugin test-quality checker by adding a multi-line detection pattern for “shape A” weak count assertions (assert!(x.len() >= N) / precomputed *_count >= N), bringing it in line with the existing multi-line handling for shapes B/C/D. It also tightens one existing plugin integration test that was using a weak > 0 count assertion.
Changes:
- Add
ML_PAT_A(multi-line “shape A”) toscripts/check-plugin-test-quality.shand wire it into the existing multi-line scan. - Extend the lint self-test script with new cases covering multi-line shape A matches and a
prop_assert!false-positive guard. - Replace a weak
balance_count > 0assertion with a strictassert_eq!(..., 1, ...)in a plugin test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scripts/test-plugin-test-quality.sh | Adds self-test cases for the new multi-line shape A lint match plus a prop_assert! guard. |
| scripts/check-plugin-test-quality.sh | Introduces ML_PAT_A and includes it in the multi-line Rust test scan. |
| crates/rustledger-plugin/tests/native_plugins_test.rs | Tightens a weak balance-assertion count check to a strict expected count. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
📊 Benchmark Results
vs main branch (2026-05-06)
What do these numbers mean?
|
Contributor
|
| Metric | Result |
|---|---|
| Check Compatibility | 99% |
| BQL Compatibility | 88% |
| Full AST Match | 99% |
| Total Files | 786 |
What's tested
- Check: Exit codes and error counts match
bean-check - BQL: Query results match
bean-query - Files: ~800 test files downloaded from 10+ beancount repositories
Full results available in workflow artifacts
This was referenced May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ci(lint): add ML_PAT_A multi-line variant for weak
>= Ncount assertionsCloses #1011.
What
scripts/check-plugin-test-quality.shhad multi-line variants forshapes B (
assert_ne!), C (!is_empty()), and D (!= 0) added in#1005. Shape A —
assert!(x.len() >= N)/ precomputed-count — onlyhad its single-line PAT_A. So a multi-line write of the original
#992 bug shape:
slipped past the lint. PR #1008 caught one such instance by hand;
PR #1012 caught two more.
Fix
Added
ML_PAT_Amirroring single-linePAT_Awith the samecount-shaped LHS restriction (
COUNT_LHS) and the negativelookbehind for
prop_assert!/debug_assert!that the othermulti-line patterns already use:
Wired into the existing
find_multiline_in_rscall.Knock-on: tightened one existing test
The new pattern caught a real instance in
test_check_drained_adds_balance_assertions_on_close:The plugin emits exactly one balance assertion per (closed account,
currency); test setup has one Close on Assets:Bank with USD only,
so we expect 1. Tightened to
assert_eq!(.count(), 1, ...).Self-test
Extended
scripts/test-plugin-test-quality.shwith 4 new cases(28 → 32 total):
assert!(\n x.len() >= 1,\n "msg"\n)assert!(\n price_count >= 1\n)(the actual [Compat]: implicit price is wrong #992 shape)assert!(\n x.count() > 0\n)prop_assert!(\n x.len() >= 1\n)must NOT fire
Verified
test functions)
scripts/check-plugin-test-quality.sh: OK (clean on current main)scripts/test-plugin-test-quality.sh: 32/32cargo clippy -p rustledger-plugin --all-features --all-targets:clean
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]