Skip to content

style: root the RuboCop project index at the tap - #23835

Merged
MikeMcQuaid merged 1 commit into
mainfrom
style-tap-project-index
Sep 6, 2026
Merged

style: root the RuboCop project index at the tap#23835
MikeMcQuaid merged 1 commit into
mainfrom
style-tap-project-index

Conversation

@p-linnane

Copy link
Copy Markdown
Contributor

brew style on a tap reports Lint/DuplicateMethods and Lint/ConstantReassignment offenses that pair the tap's methods and constants with identically named ones in a different installed tap. Taps are never loaded together, so these are false positives, and they make brew style fail on a tap whose Ruby happens to share names with any other tap on the machine.

The cause is where RuboCop roots its project index. RuboCop roots it at the directory of a .rubocop* config file and at the working directory for any other config name. brew style forces Library/.rubocop.yml for tap targets, so the index is rooted at Library and spans every installed tap, and the cross-file cops compare across all of them. The shared config excludes only a tap's top-level *.rb from those cops, so anything under cmd/, scripts/, test/ and similar collides.

This change checks a tap from its own directory through Library/tap_rubocop_style.yml, a config that only inherits the shared one. Because its name does not start with .rubocop, RuboCop roots the index at the working directory, which is the tap, so the index covers that tap alone. Cross-file detection inside the tap still works. Files spanning several taps, Homebrew's own code, and docs keep their current handling. Paths are passed as given rather than realpathed so the shared config's Taps/... exclusions keep matching a tap that is a symlink into a checkout elsewhere.

To reproduce on main, install two copies of a tap that has Ruby below its top level, then style either of them:

brew tap starhaven-io/tap
git clone https://github.com/starhaven-io/homebrew-tap "$(brew --repository)/Library/Taps/starhaven-review/homebrew-tap"
brew style starhaven-review/tap

On main this reports 127 offenses, every one naming a file in the other copy. With this change both copies are clean, a duplicate added inside one copy's scripts/ is still reported, and a duplicate hidden in a file that was not passed to brew style is still reported from a single-file run, which shows the index is rooted at the tap rather than absent.

Two specs cover the dispatch: a single-tap target gets the tap config and the tap as working directory; files spanning two taps fall back to the shared config.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI/LLM disclosure: Claude Fable 5.1 drafted the change, the config file and the specs under my direction, and I reviewed all of it. Verified with brew lgtm, brew tests --only=style, brew typecheck, and by reproducing the false positive and each of the three behaviours above against two installed copies of a tap.

Copilot AI balanced review requested due to automatic review settings September 6, 2026 00:41

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

Mixed readiness assessments and unresolved guideline nits warrant final human review.

Pull request overview

Scopes RuboCop indexing to a single tap, preventing false cross-tap offenses while preserving intra-tap detection.

Changes:

  • Adds a tap-specific RuboCop configuration.
  • Selects tap-scoped configuration and working directory.
  • Tests single- and multi-tap dispatch.
File summaries
File Description
Library/tap_rubocop_style.yml Inherits shared RuboCop settings.
Library/Homebrew/test/style_spec.rb Tests configuration dispatch.
Library/Homebrew/style.rb Selects tap-scoped RuboCop indexing.
Review details

Suppressed comments (1)

Library/Homebrew/test/style_spec.rb:289

  • This repeats the multiple-expectation pattern prohibited for simple unit examples by AGENTS.md:58. Please move both keyword-argument checks into .with(...), leaving this example with one expectation.
      expect(described_class).to receive(:system_command) do |_cmd, args:, chdir:, **|
        expect(args).to include("--config", HOMEBREW_LIBRARY/".rubocop.yml")
        expect(chdir).to eq(HOMEBREW_LIBRARY)
        result
      end
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

馃挕 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread Library/Homebrew/style.rb
Comment thread Library/Homebrew/test/style_spec.rb Outdated
RuboCop roots its project index at the directory of a .rubocop* config file and at the working directory for any other name. brew style forces Library/.rubocop.yml for tap targets, so the index spanned every installed tap and Lint/DuplicateMethods and Lint/ConstantReassignment paired one tap's methods and constants with another's. A tap is now checked from its own directory through a differently named config that inherits the shared one, so the index covers that tap alone. Paths are passed as given so the shared config's Taps exclusions keep matching a symlinked tap.

Signed-off-by: Patrick Linnane <patrick@linnane.io>
@p-linnane
p-linnane force-pushed the style-tap-project-index branch from 17db96c to e0eb4c1 Compare September 6, 2026 00:58

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good idea, thanks!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 6, 2026
Merged via the queue into main with commit 0fb6c81 Sep 6, 2026
51 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the style-tap-project-index branch September 6, 2026 11:28
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