Skip to content

Commit 3770d8e

Browse files
authored
Merge pull request #22385 from Homebrew/rubocop-todo-cleanup
Remove RuboCop TODO suppressions
2 parents ba83579 + 013aaf5 commit 3770d8e

13 files changed

Lines changed: 39 additions & 34 deletions

File tree

.github/workflows/vendor-gems.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
- name: Update RubyGems licence metadata
8888
working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}
8989
run: |
90-
BUNDLE_WITH="$(brew ruby -- -e 'require "utils/gems"; puts Homebrew.valid_gem_groups.join(":")')"
90+
BUNDLE_WITH="$(brew ruby -- -e 'require "utils/gem_setup"; puts Homebrew.valid_gem_groups.join(":")')"
9191
export BUNDLE_WITH
9292
licensed cache --config .github/licensed.yml
9393
licensed status --config .github/licensed.yml

.github/workflows/vendor-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
git check-ignore --quiet "${gem_dir}" || exit_code=$?
6363
if (( exit_code != 0 )); then
6464
if (( exit_code == 1 )); then
65-
echo "::error::VENDOR_VERSION needs bumping in utils/gems.rb" >&2
65+
echo "::error::VENDOR_VERSION needs bumping in utils/gem_setup.rb" >&2
6666
else
6767
echo "::error::git check-ignore failed" >&2
6868
fi

Library/Homebrew/.rubocop.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
inherit_from:
22
- ../.rubocop.yml
33

4-
Bundler/GemFilename:
5-
Enabled: false
6-
74
Homebrew/MoveToExtendOS:
85
Enabled: true
9-
Exclude:
10-
- "{test,requirements}/**/*"
11-
- "os.rb"
12-
13-
# We don't use Sorbet for RSpec tests so let's disable this there.
14-
Sorbet/BlockMethodDefinition:
15-
Exclude:
16-
- test/**/*
176

187
# Want to preserve our own API for these methods for now.
198
Naming/PredicatePrefix:
@@ -111,11 +100,6 @@ Style/Documentation:
111100
- version.rb
112101
- tap.rb
113102

114-
Homebrew/NegateInclude:
115-
Exclude:
116-
# YARD runs stand-alone.
117-
- yard/docstring_parser.rb
118-
119103
Style/DocumentationMethod:
120104
Include:
121105
- "formula.rb"
@@ -124,8 +108,6 @@ Style/DocumentationMethod:
124108
# No Include needed: the cop self-selects by finding @api public comments.
125109
Homebrew/PublicApiDocumentation:
126110
Enabled: true
127-
Exclude:
128-
- "vendor/**/*"
129111

130112
# Ensure cookbook-referenced methods are annotated @api public.
131113
# No Include needed: the cop self-selects from cookbook rubydoc links.

Library/Homebrew/dev-cmd/sh.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require "abstract_command"
55
require "extend/ENV"
66
require "formula"
7-
require "utils/gems"
7+
require "utils/gem_setup"
88
require "utils/shell"
99

1010
module Homebrew

Library/Homebrew/ignorable.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ def ignore
2222

2323
sig { params(blk: T.nilable(T.proc.void)).void }
2424
def self.hook_raise(&blk)
25-
# TODO: migrate away from this inline class here, they don't play nicely with
26-
# Sorbet, when we migrate to `typed: strict`
27-
# rubocop:todo Sorbet/BlockMethodDefinition
2825
Object.class_eval do
2926
alias_method :original_raise, :raise
3027

31-
sig { params(args: T.anything).void }
32-
def raise(*args)
28+
# `define_method` keeps Sorbet happy inside this `class_eval` block.
29+
define_method(:raise) do |*args|
3330
callcc do |continuation|
34-
super
31+
super(*args)
3532
# Handle all possible exceptions.
3633
rescue Exception => e # rubocop:disable Lint/RescueException
3734
unless e.is_a?(ScriptError)
@@ -44,7 +41,6 @@ def raise(*args)
4441

4542
alias_method :fail, :raise
4643
end
47-
# rubocop:enable Sorbet/BlockMethodDefinition
4844

4945
return unless block_given?
5046

Library/Homebrew/rubocops/move_to_extend_os.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ def extend_offense_message(extend_os, os_method)
2626
sig { params(node: RuboCop::AST::Node).void }
2727
def on_send(node)
2828
file_path = processed_source.file_path
29+
# The OS loader, requirements and tests need direct host checks; this
30+
# cop is for portable production code that should live under `extend/os`.
31+
return if file_path.match?(%r{(?:\A|/)Library/Homebrew/(?:requirements|test)/}) ||
32+
file_path.match?(%r{(?:\A|/)Library/Homebrew/os\.rb\z})
33+
2934
if file_path.include?("extend/os/mac/")
3035
add_offense(node, message: extend_offense_message("mac", "mac")) if os_mac?(node)
3136
add_offense(node, message: extend_offense_message("mac", "linux")) if os_linux?(node)

Library/Homebrew/standalone/init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def self.from_rubylibdir(feature)
6161
HOMEBREW_BUNDLER_VERSION = ENV.fetch("HOMEBREW_BUNDLER_VERSION").freeze
6262
ENV["BUNDLER_VERSION"] = HOMEBREW_BUNDLER_VERSION
6363

64-
require_relative "../utils/gems"
64+
require_relative "../utils/gem_setup"
6565
Homebrew.setup_gem_environment!(setup_path: false)
6666

6767
# Install gems for Rubies we don't vendor for.

Library/Homebrew/test/.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ RSpec/ContextWording:
1515
- for
1616
- which
1717
- to
18+
19+
# RSpec helper methods typecheck better as regular methods.
20+
Sorbet/BlockMethodDefinition:
21+
Enabled: false

Library/Homebrew/test/rubocops/move_to_extend_os_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@
2222
RUBY
2323
end
2424

25+
it "allows `OS.linux?` in requirements" do
26+
expect_no_offenses(<<~RUBY, "Library/Homebrew/requirements/linux_requirement.rb")
27+
OS.linux?
28+
RUBY
29+
end
30+
31+
it "allows `OS.mac?` in tests" do
32+
expect_no_offenses(<<~RUBY, "Library/Homebrew/test/example_spec.rb")
33+
OS.mac?
34+
RUBY
35+
end
36+
37+
it "allows OS checks in the OS loader" do
38+
expect_no_offenses(<<~RUBY, "Library/Homebrew/os.rb")
39+
OS.mac?
40+
RUBY
41+
end
42+
2543
context "when in extend/os/mac" do
2644
it "registers an offense when using `OS.linux?`" do
2745
expect_offense(<<~RUBY, "Library/Homebrew/extend/os/mac/foo.rb")

0 commit comments

Comments
 (0)