Skip to content

fix: use SimpleCov.skip instead of the deprecated add_filter - #456

Merged
p0deje merged 1 commit into
bazel-contrib:mainfrom
TrapsterDK:coverage-skip-filter
Nov 30, 2026
Merged

p0deje merged 1 commit into
bazel-contrib:mainfrom
TrapsterDK:coverage-skip-filter

Conversation

@TrapsterDK

Copy link
Copy Markdown
Contributor

Calls SimpleCov.skip for the coverage filters when SimpleCov has it, and add_filter otherwise.

SimpleCov 1.x deprecates add_filter in favor of skip (same arguments, same behavior) and warns when it is called. skip does not exist in 0.22, which examples/gem pins, so the helper checks SimpleCov.respond_to?(:skip) instead of switching outright.

Fixes #454

Tested: no automated test. examples/gem pins SimpleCov 0.22, so CI runs the add_filter path as before. I did not run the skip path or Ruby locally. The API difference is taken from the SimpleCov 1.x changelog and lib/simplecov/configuration/filters.rb at v1.3.2.

Assisted by Claude.

SimpleCov 1.x deprecates add_filter in favor of skip, which takes the
same arguments, and warns on every call. SimpleCov 0.22 has no skip, so
pick the method SimpleCov provides.
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The coverage configuration now uses skip when SimpleCov supports it. Otherwise, it uses add_filter. The selected method registers the built-in filters and each trimmed COVERAGE_FILTERS entry.

Changes: Coverage filter compatibility

Layer / File(s) Summary
Select and apply the filter method
ruby/private/coverage/rules_ruby_coverage.rb
The configuration selects skip when SimpleCov responds to it; otherwise, it selects add_filter. The built-in filters and trimmed COVERAGE_FILTERS entries use the selected method.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor · Severity of issue fixed: Low

Suggested reviewers: noahkawasakigoogle

Merge Risk: Minimal · up to 49138

This change avoids SimpleCov 1.x's add_filter deprecation warning and keeps SimpleCov 0.22 working through the add_filter fallback. No concrete merge-blocking risk was identified.

Architecture risk: Low · up to 49138

The change affects 1 source area.

Changed areas: ruby

Review details

Systems and components

  • observed — 1 changed file mapped to ruby.

Before / after behavior

  • observed — Modified behavior in ruby/private/coverage/rules_ruby_coverage.rb: The configuration selects skip when SimpleCov responds to it, and falls back to add_filter otherwise.
  • observed — Modified behavior in ruby/private/coverage/rules_ruby_coverage.rb: The built-in filters and trimmed COVERAGE_FILTERS entries are now registered through the selected filter method instead of always calling add_filter.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the coverage helper now calls SimpleCov.skip instead of the deprecated add_filter. It matches the raw summary and the PR objectives, so it is specific and accurate.
Description check Passed The description states that the helper calls SimpleCov.skip when available and add_filter otherwise. It also explains the SimpleCov 0.22 compatibility reason and the untested status, which matches the…
Linked Issues check Passed [#454] requires that the coverage helper stop calling add_filter under SimpleCov 1.x, keep SimpleCov 0.22 working, and use skip when SimpleCov responds to it. At head, `ruby/private/coverage/rules…
Out of Scope Changes check Passed The PR changes only the coverage helper. The head file shows the change limited to the filter-registration calls and one comment line that explains the skip/add_filter choice. The JRuby and MRI ro…
Full details: Description check

Explanation

The description states that the helper calls SimpleCov.skip when available and add_filter otherwise. It also explains the SimpleCov 0.22 compatibility reason and the untested status, which matches the changed coverage helper.

Full details: Linked Issues check

Explanation

[#454] requires that the coverage helper stop calling add_filter under SimpleCov 1.x, keep SimpleCov 0.22 working, and use skip when SimpleCov responds to it. At head, ruby/private/coverage/rules_ruby_coverage.rb sets skip_filter = SimpleCov.respond_to?(:skip) ? :skip : :add_filter and applies it through SimpleCov.public_send(skip_filter, ...) to the /external/, /spec/, and /test/ filters and to each trimmed COVERAGE_FILTERS entry. This matches the proposal in the issue. The add_filter fallback keeps the 0.22 path. No automated test covers the skip path. The 1.x behavior (no warning) rests on the changelog and the v1.3.2 source cited in the PR, not on a run. The issue does not require a test, so this does not fail the check. The full base-to-head text diff could not be read. The head file content and the PR summary (+7/-4) were used instead.

Full details: Out of Scope Changes check

Explanation

The PR changes only the coverage helper. The head file shows the change limited to the filter-registration calls and one comment line that explains the skip/add_filter choice. The JRuby and MRI root and output settings, the formatter configuration, and the LoadError handling are unchanged in the head file. All changes relate to #454. No unrelated change was found in the evidence available. The base-side diff could not be read, so the +7/-4 count comes from the PR summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: b9880cce-8010-4bd6-b808-aa81c3e76213
Commits

Reviewing files that changed from the base of the PR and between 81a3c0a and 4913809.

Files selected for processing: 1

  • ruby/private/coverage/rules_ruby_coverage.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@p0deje
p0deje merged commit fc48613 into bazel-contrib:main Nov 30, 2026
33 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coverage helper uses add_filter, deprecated in SimpleCov 1.x

2 participants