fix(output): Code Climate bands negative MI as minor
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Start with src/output/code_climate.rs, especially severity_band, and inspect the metric-direction logic around its non-finite guard. Reproduce the negative MI and zero-limit cases using the Code Climate output tests, then update the band table tests so both saturated breaches map to the top severity without changing existing bands.
Written by the indexing model from the issue text.
Description
severity_band (src/output/code_climate.rs) returns the declared floor (minor for a warning) whenever value <= 0.0 or limit <= 0.0, before it decides the metric's direction. For the lower-is-worse mi.* family, a value at or below zero is the deepest possible breach, so the worst offenders get the mildest band. An mi.original of 10 against a limit of 100 gets blocker (severity_band_table_mi_family_inverts), while −15 against the same limit gets minor.
Reproducer (found while fixing #1617): a 200-line Python function of ternary assignments (negative_mi_python in big-code-analysis-cli/tests/check/check_baseline.rs) has mi.original ≈ −14.8 and mi.sei ≈ −76.5. bca check --threshold mi.original=20 --threshold mi.sei=100 --format code-climate emits "severity": "minor" for both.
The same guard floors a higher-is-worse breach of a zero limit (--threshold cyclomatic=0), whose ratio is unbounded, at the mildest band too.
Fix: keep the NaN/non-finite guard, but rank a saturated breach (a lower-is-worse value ≤ 0, or a zero limit) at the top band rather than the floor. #1617 made the CLI's summary ranking (Violation::cmp_severity) treat that case as the worst; Code Climate should agree. Tests: negative MI → top band; zero-limit breach → top band; the existing band table unchanged.
Resolution
Commit: 49d2e7be on fix/batch-2026-10-17 (fix(cli,output): gate and rank on Threshold, shared with #1617 and #1616; the branch is rewritten and awaits a force-push).
Root cause: severity_band returned the declared floor for value <= 0 || limit <= 0 before deciding direction, so the deepest MI breach and every zero-limit breach got the mildest band — while the CLI ranked the same input as the worst. Opposite answers from two copies of the same rule (#1621).
Change: the signature and the public OffenderRecord input are unchanged. Inside, the band is computed from metric_catalog::Threshold::severity — the key bca check ranks on — with the same 1.5 / 2 / 4 cutoffs: MI 0 vs floor 20 → critical, −40 → blocker, −0.1 → major, any zero-limit breach → blocker. A record that does not breach its limit keeps the severity it declares (public fields allow a hand-built value == limit == 0); unknown ids and non-finite values still fall back to the declared floor; worst_severity(band, floor) is kept so a declared Error never renders below major.
Tests: severity_band_table_mi_family_inverts and severity_band_falls_back_when_limit_zero were wrong by construction and are rewritten to the new contract; new tests for the MI bands through zero, the zero-limit blocker, and the non-breaching record. An e2e parity check: for the 200-line Python fixture with cyclomatic=1, cognitive=15, mi.original=20, mi.visual_studio=10, the CLI's top-offender order (cyclomatic, cognitive, mi.original, mi.visual_studio) matches the Code Climate bands (blocker, blocker, critical, major).
Gate: BCA_GATE: pass (gate=pre-commit).
- Dominant language
- Rust
- Stars
- 32
- Forks
- 3
- Avg merge
- 2d 57m
- Merged PRs (30d)
- 58
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dekobon/big-code-analysis
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
dekobon/big-code-analysis#1713 ·
Maintainers usually reply within 1 day
-
bug python vcs
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
dekobon/big-code-analysis#1624 · 1 comment ·
Maintainers usually reply within 1 day
-
cli documentation
Difficulty 1/5 Under an hour Newbie friendliness 85/100
dekobon/big-code-analysis#1485 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dekobon/big-code-analysis#1458 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
dekobon/big-code-analysis#1444 ·
Maintainers usually reply within 1 day
All issues in dekobon/big-code-analysis
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
manuscript-lang/manuscript#1364 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
fable-compiler/Fable#5157 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
C-bug needs-triage O-UEFI T-libs
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day