Document cops in config, add a 100% coverage gate, and modernize support_autocorrect?#92
Merged
hellosweta merged 3 commits intoJun 9, 2026
Conversation
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>
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
A quality pass over the cops, in three independent parts (each its own commit):
1. Documented cops in
config/default.ymlEvery cop now carries a
Description(used byrubocop --show-copsand the docs generator) and aVersionAdded, per RuboCop's documented-cop convention.VersionAddedis 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-leveldef support_autocorrect?; false; end. That was the supported override on the legacyRuboCop::Cop::CopAPI, but these cops subclass the modernRuboCop::Cop::Base, where autocorrect support is read from the class method (defaultfalse) 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 reportsupport_autocorrect? == falseat the class level (verified at runtime).TypedPublicApisis intentionally untouched (it inheritstruefromSorbet::StrictSigil).3. 100% line + branch coverage gate on the cops
Added
simplecov(dev dependency) and a.simplecovthat 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-leveldef(no class/module) and dynamic/non-constantinclude.RootNamespaceIsPackName: non-.rbfile and file outside any pack.PackwerkLite::Dependency: the temporarily-ignoredPncApiconstant and an already-recordedpackage_todo.ymldependency violation.PackwerkLite::Privacy: an already-recordedpackage_todo.ymlprivacy violation.DesiredZeitwerkApi: a direct unit spec covering theapp/,lib/, and neither cases.Two genuinely defensive branches (a Zeitwerk single-file invariant
raise, and anilguard unreachable for theapp/paths the cop feeds) are marked# :nocov:with justifications.Verification
COVERAGE=true bundle exec rspec→ 81 examples, 0 failures; 100% line (209/209), 100% branch (82/82).bundle exec srb tc→ no errors.bundle exec rubocopclean on all changed files. (Two pre-existingSorbet/StrictSigiloffenses onlib/rubocop/packs/{plugin,version}.rbare present onmainand left untouched — out of scope.)🤖 Generated with Claude Code