Skip to content

fix(ci): stop a narrow subprocess-ratchet scan from wiping the baseline - #3751

Merged
zackees merged 1 commit into
masterfrom
fix/subprocess-checker-subset-baseline
Jul 28, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/subprocess-checker-subset-baseline

Conversation

@zackees

@zackees zackees commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #3748. Found while checking #3749's new test file against the ratchet.

The bug

Running the checker against a single file:

subprocess_capture_checker.py ci/tests/some_file.py

reported "239 baselined subprocess usage(s) are now gone" — because the improvement check compared the entire baseline against one file's findings. Every entry for a file that was simply never examined counted as fixed.

The wrong message is bad. The action it invites is worse: adding --update-baseline to that same narrow command rewrote the baseline from just that file, silently deleting the other 128 entries and turning the ratchet off across the repo. The next raw Popen would have gone in unnoticed — the failure mode being that a guard reports success while no longer guarding anything.

Fix

Both halves now key off the set of files actually scanned:

  • --update-baseline merges instead of overwriting, keeping entries for unscanned files verbatim. A file that genuinely improved still shrinks or drops out, so incremental tightening still works — it just can't delete what it didn't look at.
  • The "now gone" note only counts entries for files this run examined.

Baseline cleanup

Also drops the two check_array_params / check_noexcept SRC004 entries that #3747 resolved. The baseline in #3748 was generated just before #3747 merged, so it was stale by exactly those two. Full scan is now exact — no residual note.

Tests

ci/tests/test_subprocess_checker_baseline.py covers:

  • narrow --update-baseline preserves unscanned entries
  • narrow scan doesn't claim unexamined entries improved
  • a rescanned file can still shrink (the ratchet must stay tightenable)
  • a genuinely new violation still fails

The first three fail against the previous implementation; the fourth passes both, which is the correct split — it's the property that must not regress while fixing the others.

Validation

556 passed, 39 skipped in ci/tests; bash lint green.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved baseline updates so scanning selected files no longer removes findings recorded for files not included in the scan.
    • Prevented misleading “resolved” reports for files that were not examined.
    • Preserved accurate baseline reductions when previously flagged files are rescanned and improved.
  • Tests

    • Added coverage for baseline preservation, accurate improvement reporting, and detection of new violations.

Found while checking PR #3749's new test against the ratchet. Running

    subprocess_capture_checker.py ci/tests/some_file.py

reported "239 baselined subprocess usage(s) are now gone" -- because the
improvement check compared the whole baseline against a single file's
findings. Every entry for a file that was simply not examined counted as
fixed.

That message is wrong on its own, but the dangerous part is the action it
invites: adding --update-baseline to that same narrow command rewrote the
baseline from just that file, silently deleting the other 128 entries and
turning the ratchet off across the repo. The next raw Popen would have gone
in unnoticed.

Both halves now key off the set of files actually scanned:

- --update-baseline merges instead of overwriting, keeping entries for
  unscanned files verbatim. A file that genuinely improved still shrinks or
  drops out, so the ratchet can still be tightened incrementally.
- The "now gone" note only counts entries for files this run looked at.

Also drops the two check_array_params/check_noexcept SRC004 entries that
#3747 resolved -- the baseline was generated just before that merged, so it
was stale by exactly those two.

Tests cover the narrow-update case, the misleading note, that a rescanned
file can still shrink, and that a genuinely new violation still fails. The
first three fail against the previous implementation.

Validated: 556 passed / 39 skipped in ci/tests, lint green.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The subprocess checker now tracks scanned files, preserves baseline entries for unscanned files during updates, limits “now gone” reporting to scanned files, and adds regression tests. Two obsolete SRC004 baseline entries are removed.

Changes

Subprocess baseline ratcheting

Layer / File(s) Summary
Scoped baseline merge and reporting
ci/lint_python/subprocess_capture_checker.py
Path helpers and scanned-file tracking scope baseline updates and improvement reporting to files examined in the current run.
Regression coverage and baseline refresh
ci/tests/test_subprocess_checker_baseline.py, ci/lint_python/subprocess_baseline.txt
Tests cover unscanned-entry preservation, genuine rescanning improvements, new violations, and the updated baseline entries.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • FastLED/FastLED#3748: Both changes modify subprocess baseline update and per-file ratcheting behavior.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: preventing narrow subprocess-ratchet scans from wiping baseline entries.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/subprocess-checker-subset-baseline

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ci/tests/test_subprocess_checker_baseline.py`:
- Around line 51-53: Annotate the capsys parameter in
test_narrow_scan_does_not_claim_unscanned_entries_improved with the appropriate
pytest capture fixture type, preserving the existing tmp_path annotation and
test behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 21c32961-877e-47b6-a6e2-2ec1a4a7cb9d

📥 Commits

Reviewing files that changed from the base of the PR and between 4da8f6b and c0512d9.

📒 Files selected for processing (3)
  • ci/lint_python/subprocess_baseline.txt
  • ci/lint_python/subprocess_capture_checker.py
  • ci/tests/test_subprocess_checker_baseline.py
💤 Files with no reviewable changes (1)
  • ci/lint_python/subprocess_baseline.txt

@zackees
zackees merged commit dd791b4 into master Jul 28, 2026
14 checks passed
@zackees

zackees commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Fixed in 3416ce9 — annotated capsys as CaptureFixture[str]. Valid catch; the project requires explicit annotations on all parameters and I'd left that one bare.

bash lint green (ruff + ty), 4/4 tests still passing.

@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant