Repository navigation
test(metrics): kill the first wave of escaped mutants and fix two Display lines - #1881
Merged
Merged
Conversation
`cognitive::Stats` printed the space's own score under `sum`, so a file or a class read `sum: 0` whatever its functions scored; the JSON `sum` field and every sibling metric's `Display` print the subtree's sum. It also wrote `min:` with no space, and `nexits::Stats` had no comma between `average` and `min`. The two earlier fixes of this kind are nom's missing commas (#117) and nargs's headline that diverged from its sums. Found by writing the `Display` tests the mutation run asked for: no test read either line, so replacing `fmt` with `Ok(())` passed. Each test asserts the whole line against values counted from its fixture. Refs #1736
Six mutants in `line_set.rs` survived the mutation run because every test that reached them held a set starting at word 0, where adding an offset and subtracting it compute the same index, or compared sets whose last words coincided: - `subtract` read the other set at `word + other.first_word`; - `last_word` counted one or two words too many, so `union_with` reserved zero padding no row shows; - `reserve` resized to `word + first_word + 1`; - `eq` ended its comparison at `first_word * len`, short of a row past the other set's last word. Four tests, each replayed against its mutants and failing at the assertion written for them. The two over-reserve cases assert `words.len()`, as `dense_rows_cost_one_word_per_sixty_four` does: row equality ignores padding by design. Refs #1736
`CCode::compute` shares its condition helpers with C++, and the C-family parity tests pin those. Its assignment, initialised-declarator, call and `else` arms had no fixture at all: deleting any of them, or turning its `+=` into `-=`, passed the suite. Four tests, one per arm, each on a fixture only that arm can score. `abc::Stats`'s `Display` had no reader either. Its test uses counts of 2, 3 and 6, whose magnitude is 7, so a value under the wrong label shows. Each test was replayed against its mutants; the whole of `abc/c.rs` now leaves two survivors, both on the `init_declarator` guard, which the pinned C grammar makes always true. Refs #1736
Two paths of `ObjcCode`'s `Npa` had no fixture that could tell them from a constant: - a `@optional` / `@required` group was only ever given one property, so `objc_count_group_properties` returning 1 passed; - every fixture was an `@interface` or a `@protocol`, so the class bucket an `@implementation`'s instance variables feed was never read. Both tests were replayed against `npa/objc.rs`, which now leaves no survivor. Refs #1736
… returns The per-space accessors of `npm`, `npa` and `wmc` were asserted only on an interface with one member, so `interface_npm`, `interface_nm`, `interface_npa`, `interface_na` and `interface_wmc` returning 1 passed. `nom`'s `closures()` had no reader, and `functions()` none that saw 0. Each now has a fixture where it reads a value that is neither 0 nor 1: a Java interface and class with several members, and an Objective-C method holding two block literals, which open no space of their own. `wmc::Stats::merge` passes a nested class's complexity up through a function nested in a method; negating that term passed, because no fixture put a class inside a nested function. A Python one does. `cyclomatic`, `tokens` and `loc` had no `Display` test. The first two assert the whole line against hand-counted values; `loc` has 24 fields, so its test restates the label and accessor table and anchors it with two literal fragments. Refs #1736
Three are equivalent and one never terminates; each entry carries its proof: - `LineSet::reserve` with `<=`: at `word == first_word` both branches leave the set untouched. - the `==` to `!=` flip inside the `init_declarator` guard of the C and Objective-C ABC impls: the pinned grammars give every such node an `=` child and another child, so one child scan finds a match either way. - `for_each_named_child` with its `!` deleted: a one-child list loops forever, and the Go ABC tests that return one value hang on it. The guard's replacement by `true` is not excluded. It skips the guard's child scan, which the scan counter observes, so it is not equivalent in the sense the file states. The guide gains two short sections: how to replay chosen mutants and read their logs, and how to write an entry that matches one mutant and survives edits above it. Both note that cargo-mutants 27.1.0 applies no name filter to `delete field` mutants. Refs #1736
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1881 +/- ##
==========================================
+ Coverage 98.47% 98.49% +0.01%
==========================================
Files 403 403
Lines 124408 124680 +272
Branches 123973 124245 +272
==========================================
+ Hits 122511 122803 +292
+ Misses 1173 1153 -20
Partials 724 724
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
CI's `clippy` job installs the `stable` tip, which is Rust 1.100 as of today, and that clippy reports `fn _native` as a used underscore-prefixed item: `#[pymodule]`'s expansion calls it. The underscore is the Python module's name (`big_code_analysis._native`), so the function keeps it and carries the allow with that reason. The local gate could not see this on 1.99.0. Checked with a 1.100.0 toolchain: `cargo clippy --workspace --all-targets --all-features --keep-going -- -D warnings` reported this one error before the change and none after; `cargo fmt --check` and `cargo doc` with `-D warnings` pass on it too. Fixes #1882
This was referenced Nov 12, 2026
This branch was previously deployed
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.
First wave of work on #1736. It kills the escaped mutants from the old run that are still live in the root crate's
loc,abc,npa,npm,nom,wmc,cognitive,cyclomatic,nexitsandtokensfiles, fixes twoDisplaydefects the new tests exposed, and adds fourexclude_reentries with their proofs.Refs #1736. This does not close it: the close condition is a
mutation-test.ymlrun onmainwith every shard complete, zero missed and zero timed out, and later waves follow the fresh inventory from run 43278927651.Commits
fix(cognitive,nexits)cognitive::Statsprinted the space's own score undersumand wrotemin:with no space;nexits::Statshad no comma afteraverage. Same family as #117. Changelog entry includedtest(loc)LineSettests at non-zero word offsetstest(abc)elsearms, which had no fixture; one forabc::Stats'sDisplaytest(npa)@implementationinstance variables (the class bucket)test(metrics)npm,npa,wmc,nomat values a constant cannot return; a class inside a function nested in a method forwmc::Stats::merge;Displayforcyclomatic,tokens,locci(mutation)docs/development/mutation_testing.mdon replaying chosen mutants and writing an entryEvidence
cargo mutants --in-place -f <file> -F <name>(cargo-mutants 27.1.0, rustc 1.99.0), and the failing assertion read from each mutant's log.src/metrics/abc/c.rs38 caught, 2 missed (theinit_declaratorguard, below);src/metrics/npa/objc.rs43 caught, 0 missed.// expected:derivation beside each. A fresh-context review re-derived all of them and found no discrepancy.make pre-commit:BCA_GATE: pass (gate=pre-commit)..cargo/mutants.tomlcomments and the doc sections were edited after that run;make markdown-lint,make toml-lintandcargo fmt --checkwere re-run and pass.Exclusions
cargo mutants --list --no-configagainstcargo mutants --listover the workflow's selection differs by exactly these four:LineSet::reserve,<to<=word == first_wordboth branches leave the set untouched==to!=in theinit_declaratorguard, C ABC=child and another childkind == MessageExpressionsitedelete ! in for_each_named_childLeft open on purpose
init_declaratorguard replaced bytrue, in C and Objective-C. It changes no metric but skips the guard's child scan, whichchild_scan_cursorsobserves, so it is not excluded. The next wave drops the guard in those two impls instead.privatemethod is counted as public bynpm. Not fixed here.