Skip to content

Document cops in config, add a 100% coverage gate, and modernize support_autocorrect?#92

Merged
hellosweta merged 3 commits into
rubyatscale:mainfrom
corsonknowles:dck/cop-quality-docs-coverage
Jun 9, 2026
Merged

Document cops in config, add a 100% coverage gate, and modernize support_autocorrect?#92
hellosweta merged 3 commits into
rubyatscale:mainfrom
corsonknowles:dck/cop-quality-docs-coverage

Conversation

@corsonknowles

Copy link
Copy Markdown
Contributor

What & why

A quality pass over the cops, in three independent parts (each its own commit):

1. Documented cops in config/default.yml

Every cop now carries a Description (used by rubocop --show-cops and the docs generator) and a VersionAdded, per RuboCop's documented-cop convention. VersionAdded is backfilled from git history (Packs/*0.0.2, PackwerkLite/*0.0.12).

2. Modernized support_autocorrect?

Five cops (ClassMethodsAsPublicApis, DocumentedPublicApis, RootNamespaceIsPackName, PackwerkLite::Privacy, PackwerkLite::Dependency) defined an instance-level def support_autocorrect?; false; end. That was the supported override on the legacy RuboCop::Cop::Cop API, but these cops subclass the modern RuboCop::Cop::Base, where autocorrect support is read from the class method (default false) and the instance method is deprecated/ignored. The overrides were dead code left over from the old API, so they're removed. Behavior is unchanged — all five already report support_autocorrect? == false at the class level (verified at runtime). TypedPublicApis is intentionally untouched (it inherits true from Sorbet::StrictSigil).

3. 100% line + branch coverage gate on the cops

Added simplecov (dev dependency) and a .simplecov that enforces 100% line and 100% branch coverage over the cop surface (lib/rubocop/cop/**) on full runs / COVERAGE=true. Closed the gaps with real specs:

  • ClassMethodsAsPublicApis: top-level def (no class/module) and dynamic/non-constant include.
  • RootNamespaceIsPackName: non-.rb file and file outside any pack.
  • PackwerkLite::Dependency: the temporarily-ignored PncApi constant and an already-recorded package_todo.yml dependency violation.
  • PackwerkLite::Privacy: an already-recorded package_todo.yml privacy violation.
  • DesiredZeitwerkApi: a direct unit spec covering the app/, lib/, and neither cases.

Two genuinely defensive branches (a Zeitwerk single-file invariant raise, and a nil guard unreachable for the app/ paths the cop feeds) are marked # :nocov: with justifications.

Verification

  • COVERAGE=true bundle exec rspec81 examples, 0 failures; 100% line (209/209), 100% branch (82/82).
  • bundle exec srb tc → no errors.
  • bundle exec rubocop clean on all changed files. (Two pre-existing Sorbet/StrictSigil offenses on lib/rubocop/packs/{plugin,version}.rb are present on main and left untouched — out of scope.)

🤖 Generated with Claude Code

corsonknowles and others added 2 commits June 6, 2026 09:31
RuboCop's documented-cop convention expects each cop entry to carry a
Description (used by the docs generator and `rubocop --show-cops`) and a
VersionAdded. Backfilled from git history: Packs/* shipped in 0.0.2,
PackwerkLite/* in 0.0.12.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rrect?

- Add simplecov (dev dep) and a .simplecov gate enforcing 100% line + branch
  coverage on the cop surface (lib/rubocop/cop/**).
- Remove the deprecated instance-level `support_autocorrect?` overrides from the
  five cops that subclass the modern RuboCop::Cop::Base. On Base, autocorrect
  support is read from the class method (default false); the instance override
  is dead and was a leftover from the legacy RuboCop::Cop::Cop API. Behavior is
  unchanged (all five already reported false at the class level).
- Close the remaining coverage gaps with real specs: top-level/dynamic-mixin
  cases for ClassMethodsAsPublicApis, non-rb / not-in-a-pack guards for
  RootNamespaceIsPackName, the PncApi skip and package_todo dependency case for
  PackwerkLite::Dependency, the package_todo privacy case for PackwerkLite::Privacy,
  and a DesiredZeitwerkApi unit spec (app/lib/neither).
- Mark two genuinely defensive branches with `# :nocov:` and a justification.

81 examples, 0 failures; 100% line + 100% branch on the cop files.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@corsonknowles corsonknowles requested a review from a team as a code owner June 6, 2026 18:11
@github-project-automation github-project-automation Bot moved this to Triage in Modularity Jun 6, 2026

@hellosweta hellosweta 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.

🧪

- plugin.rb: bump to `# typed: strict`, add `extend T::Sig` and sigs on
  about/supported?/rules (lint_roller RBI provides the types).
- version.rb: exclude from Sorbet/StrictSigil instead of making it strict —
  the gemspec require_relatives it before sorbet-runtime loads, so a
  `T.let` here would raise NameError on bundle/gem build.
- Regenerate manual/ (VersionAdded now synced from config/default.yml).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hellosweta hellosweta merged commit 307ee8f into rubyatscale:main Jun 9, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Triage to Done in Modularity Jun 9, 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.

2 participants