Skip to content

Redesign configuration DSL around cover/skip/group - #1188

Merged
sferik merged 1 commit into
mainfrom
config-api-redesign
May 26, 2026
Merged

sferik merged 1 commit into
mainfrom
config-api-redesign

Conversation

@sferik

@sferik sferik commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Replaces SimpleCov's 60-method configuration grab bag with a smaller, consistent vocabulary, with full backward compatibility via per-method deprecation warnings that name their exact replacement (including the user's actual arguments).

The new spelling collapses three classes of inconsistency in the old API:

  • Verb shape: add_filter, track_files, enable_coverage, use_merging, formatter were five different verb shapes for the same kind of operation. Replaced with three short verbs (cover, skip, group) and consistent prefix-based families (merge_*, *_coverage, at_*).
  • String matcher semantics: add_filter "lib" was a path-segment substring; track_files "lib" was a glob. New cover keeps track_files's glob semantics for strings (matching the "this is the set of files I want reported" mental model). skip keeps add_filter's substring semantics for ergonomic continuity with the deprecated method.
  • Missing allowlist: there was no positive counterpart to add_filter. Users had to invert filters by hand. cover is that counterpart, and unlike a simple inclusion filter it also seeds disk discovery so files matching a glob appear in the report at 0% coverage even when not required during the run (the legacy track_files behavior, folded into the same call).
Legacy New Notes
add_filter "lib/legacy" skip "lib/legacy" Same matcher grammar (string = path-segment substring; Regexp; block; Array). No behavior change.
add_group "Models", "app/models" group "Models", "app/models" Same matcher grammar. No behavior change.
track_files "lib/**/*.rb" cover "lib/**/*.rb" cover includes unloaded files and restricts the report to the matching set. To keep the legacy additive-only behavior, pass every directory you want reported, e.g. cover "lib/**/*.rb", "app/**/*.rb".
use_merging false merging false Same value.
enable_for_subprocesses true merge_subprocesses true Same value.
enable_coverage_for_eval enable_coverage :eval Eval coverage now folds into the same call: enable_coverage :branch, :eval.
print_error_status (reader) print_errors Reader only. The print_error_status= writer is unaffected.

Brand-new in this PR (no legacy method to migrate from):

  • cover — positive scope (allowlist). See above for the relationship with track_files.
  • no_default_skips — clear every previously-installed filter so subsequent skips start clean.

Replace the 60-method configuration grab bag with a smaller, consistent
vocabulary: `cover` (the long-requested positive scope counterpart to
`add_filter`, with string-glob semantics that match `track_files`),
`skip` (renamed `add_filter`), `group` (renamed `add_group`),
`no_default_skips`, `merging`, `merge_subprocesses`, `print_errors`, and
a variadic `enable_coverage` that accepts `:eval`. Every legacy method
continues to work but emits a deprecation warning naming the exact
replacement and the user's actual arguments.
@sferik
sferik force-pushed the config-api-redesign branch from 25484d7 to 93a0781 Compare May 25, 2026 03:40
@sferik
sferik merged commit 4468540 into main May 26, 2026
24 checks passed
@sferik
sferik requested a review from Copilot May 26, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR redesigns SimpleCov’s configuration DSL around cover, skip, and group, while keeping legacy methods functional with deprecation warnings.

Changes:

  • Adds cover/skip/group APIs and deprecates legacy configuration methods.
  • Adds cover-filter integration into result processing and unloaded-file discovery.
  • Updates docs, changelog, profiles, and specs for the new DSL and formatter opt-out behavior.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
lib/simplecov/configuration.rb Adds new DSL methods, deprecation wrappers, formatter opt-out, and parallel test configuration.
lib/simplecov/filter.rb Adds GlobFilter for cover string glob semantics.
lib/simplecov/result.rb Applies cover filters and supports no-formatter opt-out.
lib/simplecov.rb Uses new config names and refactors unloaded-file discovery.
lib/simplecov/profiles/*.rb Migrates bundled profiles to the new DSL.
README.md / CHANGELOG.md Documents the migration and new features.
Specs/features/config files Updates and expands test coverage for the new configuration behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# never required during the suite.
#
def cover_globs
cover_filters.grep(SimpleCov::GlobFilter).map(&:filter_argument)
Comment on lines +127 to +131
warn "#{Kernel.caller.first}: [DEPRECATION] `SimpleCov.track_files` is deprecated. " \
"Replace with `SimpleCov.cover #{glob.inspect}` — `cover` includes unloaded files on disk " \
"(the historical `track_files` behavior) and also restricts the report to the matching set. " \
"If you want to keep additional files outside #{glob.inspect} in the report, pass every " \
"directory you care about, e.g. `cover #{glob.inspect}, \"app/**/*.rb\"`."
Comment on lines +656 to +658
warn "#{Kernel.caller.first}: [DEPRECATION] `SimpleCov.add_filter` is deprecated. " \
"Replace with `SimpleCov.skip` (same arguments, same behavior). Example: " \
"`SimpleCov.skip #{filter_argument.inspect}`."
Comment on lines +703 to +705
warn "#{Kernel.caller.first}: [DEPRECATION] `SimpleCov.add_group` is deprecated. " \
"Replace with `SimpleCov.group` (same arguments, same behavior). Example: " \
"`SimpleCov.group #{group_name.inspect}, #{filter_argument.inspect}`."
Comment thread README.md

The configuration DSL was redesigned to use a smaller set of consistent verbs.
The legacy methods continue to work but emit deprecation warnings that name
their replacement; the table below is the canonical migration map.
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.

2 participants