Skip to content

Get to 100% line, branch and method coverage - #781

Open
sferik wants to merge 2 commits into
ruby-oauth:mainfrom
sferik:full-coverage
Open

sferik wants to merge 2 commits into
ruby-oauth:mainfrom
sferik:full-coverage

Conversation

@sferik

@sferik sferik commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

This gets line, branch and method coverage to 100% and turns on kettle-soup-cover's new strict mode to keep it there. A run below 100% on any of the three fails, locally and in the coverage workflow.

Coverage was already close. Line coverage went from 98.48% to 100%, branch from 93.53% to 100%, and method from 98.99% to 100%. Most of the gap was SanitizedLogFormatter, so most of the 13 new specs log real requests and responses through it: redacting code= in a logged URL without touching the actual request, string bodies shaped like Hash#inspect, non-string bodies, nil values, cyclic arrays, and envs without a URL or body. The rest cover Response#parser memoization and protocol-relative redirects for a location without query= or fragment=. Three branches can't be reached in any single run, so they're excluded with inline simplecov:disable branch comments saying why. Two only take their else arm on Faraday 0.x, and the MultiXML/MultiXml choice depends on which multi_xml release is installed. Nothing else in lib/ changed.

The config is now just K_SOUP_COV_MIN_STRICT=true in mise.toml, .envrc and coverage.yml, from kettle-dev/kettle-soup-cover#33, with K_SOUP_COV_MIN_LINE and K_SOUP_COV_MIN_BRANCH at 100 everywhere, so nothing says 76/92 or 78/97 anymore. An earlier version of this PR loaded SimpleCov's strict profile itself and needed a couple of workarounds to stop kettle-soup-cover from overwriting it. Those are all gone. Strict mode, and the fix that keeps method coverage on in turbo_tests2 workers, shipped in kettle-soup-cover 3.0.15, so coverage.gemfile now requires it. With it, plain RSpec and turbo_tests2 both pass the full suite at 100% line, branch and method coverage, and both fail on a single uncovered method.

Copilot AI lite review requested due to automatic review settings October 26, 2026 00:09

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.

🟡 Changes recommended

Preserve the local and CI coverage settings through the repository’s templating workflow.

1 open issue
What changed in this PR

This pull request raises line, branch, and method coverage enforcement to 100% using SimpleCov’s strict profile, adds targeted coverage tests, and aligns local and CI test settings.

Changes:

  • Adds coverage specs for sanitized logging, parser memoization, and protocol-relative redirects.
  • Loads SimpleCov’s strict profile and synchronizes coverage thresholds.
  • Switches coverage runs to plain RSpec and documents unreachable compatibility branches.
  • Updates the gradual RuboCop lock.
File Description
spec/​spec_helper.rb Restores strict SimpleCov thresholds after kettle-soup-cover configuration.
spec/​oauth2/​sanitized_log_formatter_spec.rb Adds formatter edge-case and request/response logging coverage.
spec/​oauth2/​response_spec.rb Tests response parser memoization.
spec/​oauth2/​client_spec.rb Covers redirects without query and fragment writers.
mise.toml Sets local coverage thresholds and the RSpec runner.
lib/​oauth2/​sanitized_log_formatter.rb Excludes the Faraday 0.x compatibility branch.
lib/​oauth2/​response.rb Excludes the version-dependent XML parser branch.
lib/​oauth2/​client.rb Excludes the Faraday 0.x formatter branch.
.simplecov Loads the strict coverage profile when hard enforcement is enabled.
.rubocop_gradual.lock Updates recorded lint locations after spec additions.
.github/​workflows/​coverage.yml Sets CI coverage thresholds and the RSpec runner.
.envrc Aligns environment coverage thresholds and runner settings.

Review effort: Lite

Comment thread .github/workflows/coverage.yml Outdated
Copilot AI lite review requested due to automatic review settings October 26, 2026 00:22

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.

🔵 Needs a closer look

Protect the template-managed coverage settings in .envrc and mise.toml from being overwritten by future template updates.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Protect local coverage settings from template overwrites

.envrc:32

These new local coverage settings are outside a kettle-jem:freeze block, but .structuredmerge/kettle-jem.lock identifies .envrc as a generated template file and the default merge preference is template (.structuredmerge/kettle-jem.yml:583-587). A future template pass can therefore replace these values—including KETTLE_TEST_RUNNER=rspec—with the template defaults, so local runs silently return to turbo_tests2 and no longer enforce method coverage. Wrap this block in freeze markers or add an explicit destination-preferred merge rule for .envrc.

1 resolved since last review

Review effort: Lite

Add specs for the code the suite never reached:

- SanitizedLogFormatter: logging of requests and responses through a
  real logger, redaction of the code query parameter in a logged URL,
  Hash#inspect-shaped string bodies, other body types, nil values,
  cyclic arrays, and envs without a URL or body.
- Response#parser memoization.
- Client protocol-relative redirect resolution for a location object
  without query and fragment writers.

Three branches cannot be taken in a single coverage run, so they are
excluded with simplecov:disable directives that say why. Two only take
their else arm on Faraday 0.x, and the MultiXML or MultiXml choice in
the XML parser depends on the installed multi_xml release.

The .rubocop_gradual.lock change only moves two existing entries for
client_spec.rb to their new line numbers.
Copilot AI lite review requested due to automatic review settings October 26, 2026 00:35

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.

🔵 Needs a closer look

Protect the .envrc coverage settings from kettle-jem template regeneration.

No open issues 🎉

Review effort: Lite

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.

🟡 Changes recommended

Unresolved critical configuration errors can prevent coverage and spec runs from starting, and local enforcement can be bypassed.

3 open issues

Review effort: Lite

Comment thread .simplecov Outdated
Comment thread spec/spec_helper.rb Outdated
Comment thread .envrc Outdated
Copilot AI lite review requested due to automatic review settings October 26, 2026 01:16
@sferik sferik changed the title Enforce 100% coverage with SimpleCov's strict profile Get to 100% line, branch and method coverage Oct 26, 2026

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.

🔵 Needs a closer look

Update the template sources or destination-preferred configuration so .envrc and coverage.yml retain the coverage settings after regeneration.

3 open issues

Review effort: Lite

Turn on K_SOUP_COV_MIN_STRICT in mise.toml, .envrc and the coverage
workflow, so kettle-soup-cover enables method coverage and holds line,
branch and method coverage to 100%, in plain RSpec runs and in
turbo_tests2's collated result. K_SOUP_COV_MIN_LINE and
K_SOUP_COV_MIN_BRANCH go to 100 as well, so nothing still says 76/92
or 78/97, and the coverage summary step agrees.

Strict mode, and the fix that keeps method coverage on in turbo_tests2
workers, are in kettle-soup-cover 3.0.15, so require it.
Copilot AI lite review requested due to automatic review settings October 26, 2026 03:31

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.

🔵 Needs a closer look

Two moderate findings remain regarding inconsistent GitLab method-coverage enforcement and the generated workflow source.

2 open issues
1 resolved since last review

Review effort: Lite

This branch has not been deployed

No deployments
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.

3 participants