Summary
In tests/mozcpp_grammar_metrics.rs, two tests assert cyclomatic.cyclomatic_sum() >= 3 instead of the exact derivable value. In mozcpp_moz_annotated_class_metrics the true sum is well above 3, so a regression that stops counting the if decision point still satisfies >= 3 and is masked — the same bug-masking pattern as #936 (where a C cognitive assertion was > 0 instead of the exact value).
Location
tests/mozcpp_grammar_metrics.rs:66-69 (mozcpp_moz_annotated_class_metrics)
tests/mozcpp_grammar_metrics.rs:90-94 (mozcpp_qm_try_function_metrics)
Evidence
mozcpp_moz_annotated_class_metrics analyzes a MOZ_*-annotated class with two methods, one of which (parse) contains a single if:
assert!(
m.cyclomatic.cyclomatic_sum() >= 3,
"cyclomatic includes the method branch: {}",
m.cyclomatic.cyclomatic_sum()
);
Cyclomatic is seeded at 1 per space (src/metrics/cyclomatic.rs:67, cyclomatic: 1.) and compute_sum runs for every space (src/spaces.rs:442-462), so the aggregate here is:
- unit space: 1
- class
Parser: 1
- method
parse: 1 + 1 (the if, src/metrics/cyclomatic.rs:298) = 2
- method
reset: 1
Total = 5. The if decision point the test claims to guard is only 1 of those 5. If the C-family IfStatement cyclomatic arm regressed (the precise failure the docstring says this fixture protects against), the sum drops to 4 — still >= 3, so the test passes green. The assertion protects nothing against the regression it documents.
mozcpp_qm_try_function_metrics (tests/mozcpp_grammar_metrics.rs:90-94) uses the same >= 3 form on a single function whose exact sum is 3 (unit 1 + function Foo 1 + if 1). Here an if-drop (sum 2) is caught, but an over-count regression (e.g. a QM_TRY_INSPECT macro argument spuriously adding a branch) is not — >= 3 admits any value at or above the true value.
Expected Behavior
Assert the exact derivable cyclomatic sum (assert_eq!(m.cyclomatic.cyclomatic_sum(), 5, ...) and assert_eq!(..., 3, ...) respectively), so both an undercount (dropped decision point) and an overcount (spurious branch) fail the test. cyclomatic_sum() returns u64, so exact equality is safe (no float-magnitude brittleness).
Actual Behavior
>= 3 admits any sum at or above 3. In mozcpp_moz_annotated_class_metrics the true value is 5, leaving a two-point margin that masks a dropped-if regression; in mozcpp_qm_try_function_metrics any overcount escapes.
Impact
Test-only. Mozcpp owns no file extensions and has no integration-snapshot corpus (per the file's own module doc), so these unit tests are the only metric coverage for the fork. A loose threshold here is the only line of defense for the very decision-point counting the tests claim to pin, and it does not hold.
Summary
In
tests/mozcpp_grammar_metrics.rs, two tests assertcyclomatic.cyclomatic_sum() >= 3instead of the exact derivable value. Inmozcpp_moz_annotated_class_metricsthe true sum is well above 3, so a regression that stops counting theifdecision point still satisfies>= 3and is masked — the same bug-masking pattern as #936 (where a C cognitive assertion was> 0instead of the exact value).Location
tests/mozcpp_grammar_metrics.rs:66-69(mozcpp_moz_annotated_class_metrics)tests/mozcpp_grammar_metrics.rs:90-94(mozcpp_qm_try_function_metrics)Evidence
mozcpp_moz_annotated_class_metricsanalyzes aMOZ_*-annotated class with two methods, one of which (parse) contains a singleif:Cyclomatic is seeded at 1 per space (
src/metrics/cyclomatic.rs:67,cyclomatic: 1.) andcompute_sumruns for every space (src/spaces.rs:442-462), so the aggregate here is:Parser: 1parse: 1 + 1 (theif,src/metrics/cyclomatic.rs:298) = 2reset: 1Total = 5. The
ifdecision point the test claims to guard is only 1 of those 5. If the C-familyIfStatementcyclomatic arm regressed (the precise failure the docstring says this fixture protects against), the sum drops to 4 — still>= 3, so the test passes green. The assertion protects nothing against the regression it documents.mozcpp_qm_try_function_metrics(tests/mozcpp_grammar_metrics.rs:90-94) uses the same>= 3form on a single function whose exact sum is 3 (unit 1 + functionFoo1 +if1). Here anif-drop (sum 2) is caught, but an over-count regression (e.g. aQM_TRY_INSPECTmacro argument spuriously adding a branch) is not —>= 3admits any value at or above the true value.Expected Behavior
Assert the exact derivable cyclomatic sum (
assert_eq!(m.cyclomatic.cyclomatic_sum(), 5, ...)andassert_eq!(..., 3, ...)respectively), so both an undercount (dropped decision point) and an overcount (spurious branch) fail the test.cyclomatic_sum()returnsu64, so exact equality is safe (no float-magnitude brittleness).Actual Behavior
>= 3admits any sum at or above 3. Inmozcpp_moz_annotated_class_metricsthe true value is 5, leaving a two-point margin that masks a dropped-ifregression; inmozcpp_qm_try_function_metricsany overcount escapes.Impact
Test-only. Mozcpp owns no file extensions and has no integration-snapshot corpus (per the file's own module doc), so these unit tests are the only metric coverage for the fork. A loose threshold here is the only line of defense for the very decision-point counting the tests claim to pin, and it does not hold.