Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

fix(output): Code Climate bands negative MI as minor

Closed Beginner friendly
#1,620 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
cli

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

bug output

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dekobon/big-code-analysis

All issues in dekobon/big-code-analysis

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.