Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Library/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ plugins:
plugin_class_name: RuboCop::RSpec::Plugin
- rubocop-sorbet:
plugin_class_name: RuboCop::Sorbet::Plugin
- test-prof:
plugin_class_name: RuboCop::TestProf::Plugin

require:
- ./Homebrew/rubocops.rb
- test_prof/rubocop

inherit_mode:
merge:
Expand Down
22 changes: 11 additions & 11 deletions Library/Homebrew/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GEM
bindata (~> 2)
erubi (1.13.1)
hana (1.3.7)
json (2.16.0)
json (2.18.0)
json_schemer (2.4.0)
bigdecimal
hana (~> 1.3)
Expand Down Expand Up @@ -125,15 +125,15 @@ GEM
simplecov-html (0.13.2)
simplecov_json_formatter (0.1.4)
simpleidn (0.2.3)
sorbet (0.6.12806)
sorbet-static (= 0.6.12806)
sorbet-runtime (0.6.12806)
sorbet-static (0.6.12806-aarch64-linux)
sorbet-static (0.6.12806-universal-darwin)
sorbet-static (0.6.12806-x86_64-linux)
sorbet-static-and-runtime (0.6.12806)
sorbet (= 0.6.12806)
sorbet-runtime (= 0.6.12806)
sorbet (0.6.12815)
sorbet-static (= 0.6.12815)
sorbet-runtime (0.6.12815)
sorbet-static (0.6.12815-aarch64-linux)
sorbet-static (0.6.12815-universal-darwin)
sorbet-static (0.6.12815-x86_64-linux)
sorbet-static-and-runtime (0.6.12815)
sorbet (= 0.6.12815)
sorbet-runtime (= 0.6.12815)
spoom (1.7.10)
erubi (>= 1.10.0)
prism (>= 0.28.0)
Expand All @@ -154,7 +154,7 @@ GEM
spoom (>= 1.7.9)
thor (>= 1.2.0)
yard-sorbet
test-prof (1.4.4)
test-prof (1.5.0)
thor (1.4.0)
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion Library/Homebrew/test/rubocop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@
end

it "loads all Formula cops without errors" do
stdout, stderr, status = Open3.capture3(RUBY_PATH, "-W0", "-S", "rubocop", TEST_FIXTURE_DIR/"testball.rb")
# TODO: Remove these args once TestProf fixes their RuboCop plugin.
test_prof_rubocop_args = [
# Require "sorbet-runtime" to bring T into scope for warnings.rb
"-r", "sorbet-runtime",
# Require "extend/module" to include T::Sig in Module for warnings.rb
"-r", HOMEBREW_LIBRARY_PATH/"extend/module.rb",
# Work around TestProf RuboCop plugin issues
"-r", HOMEBREW_LIBRARY_PATH/"utils/test_prof_rubocop_stub.rb"
]

stdout, stderr, status = Open3.capture3(RUBY_PATH, "-W0", "-S", "rubocop", TEST_FIXTURE_DIR/"testball.rb",
*test_prof_rubocop_args)
expect(stderr).to be_empty
expect(stdout).to include("no offenses detected")
expect(status).to be_a_success
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
require "rubocop"
end

# TODO: Remove this workaround once TestProf fixes their RuboCop plugin.
# This is needed because the RuboCop RSpec plugin attempts to load TestProf's RuboCop plugin.
require "utils/test_prof_rubocop_stub"

require "rspec/github"
require "rspec/retry"
require "rspec/sorbet"
Expand Down
17 changes: 2 additions & 15 deletions Library/Homebrew/utils/rubocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,7 @@
require "rubocop"
end

# TestProf is not able to detect what version of RuboCop we're using, so we need to manually import its cops.
# For more details, see https://github.com/test-prof/test-prof/blob/v1.4.4/lib/test_prof/rubocop.rb
Warnings.ignore(/TestProf cops require RuboCop >= 0.51.0 to run/) do
# All this file does is check the RuboCop version and require the files below.
# If we don't require this now while the warning is ignored, we'll see the warning again later
# when RuboCop requires the file.
require "test_prof/rubocop"

# This is copied from test-prof/rubocop.rb, and is necessary because that file returns early if the RuboCop version
# check isn't met.
# Note: when the next version of TestProf is released, this will need to change to support RuboCop's plugin system.
# See: https://github.com/test-prof/test-prof/pull/321
require "test_prof/cops/inject"
require "test_prof/cops/rspec/aggregate_examples"
end
# TODO: Remove this workaround once TestProf fixes their RuboCop plugin.
require_relative "test_prof_rubocop_stub"

exit RuboCop::CLI.new.run
43 changes: 43 additions & 0 deletions Library/Homebrew/utils/test_prof_rubocop_stub.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# typed: strict
# frozen_string_literal: true

require_relative "../warnings"

# TestProf's RuboCop plugin has two issues that we need to work around:
#
# 1. It references RuboCop::TestProf::Plugin::VERSION, which does not exist.
# To solve this, we define the constant ourselves, which requires creating a dummy LintRoller::Plugin class.
# This should be fixed in the next version of TestProf.
# See: https://github.com/test-prof/test-prof/commit/a151a513373563ed8fa7f8e56193138d3ee9b5e3
#
# 2. It checks the RuboCop version using a method that is incompatible with our RuboCop setup.
# To bypass this check, we need to manually require the necessary files. More details below.

module LintRoller
# Dummy class to satisfy TestProf's reference to LintRoller::Plugin.
class Plugin; end # rubocop:disable Lint/EmptyClass
end

module RuboCop
module TestProf
class Plugin < LintRoller::Plugin
VERSION = "1.5.0"
end
end
end

# TestProf is not able to detect what version of RuboCop we're using, so we need to manually import its cops.
# For more details, see https://github.com/test-prof/test-prof/blob/v1.5.0/lib/test_prof/rubocop.rb
# TODO: This will change in the next version of TestProf.
# See: https://github.com/test-prof/test-prof/commit/a151a513373563ed8fa7f8e56193138d3ee9b5e3
Warnings.ignore(/TestProf cops require RuboCop >= 0.51.0 to run/) do
# All this file does is check the RuboCop version and require the files below.
# If we don't require this now while the warning is ignored, we'll see the warning again later
# when RuboCop requires the file.
require "test_prof/rubocop"

# This is copied from test-prof/rubocop.rb, and is necessary because that file returns early if the RuboCop version
# check isn't met.
require "test_prof/cops/plugin"
require "test_prof/cops/rspec/aggregate_examples"
end
14 changes: 7 additions & 7 deletions Library/Homebrew/vendor/bundle/bundler/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def self.extension_api_version
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/elftools-1.3.1/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/erubi-1.13.1/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/hana-1.3.7/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/json-2.16.0")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/json-2.16.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/json-2.18.0")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/json-2.18.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/regexp_parser-2.11.3/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simpleidn-0.2.3/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/json_schemer-2.4.0/lib")
Expand Down Expand Up @@ -89,7 +89,7 @@ def self.extension_api_version
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-3.13.2/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-github-3.0.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-retry-0.6.2/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-runtime-0.6.12806/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-runtime-0.6.12815/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-sorbet-1.9.2/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec_junit_formatter-0.6.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-ast-1.48.0/lib")
Expand All @@ -109,17 +109,17 @@ def self.extension_api_version
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov_json_formatter-0.1.4/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-0.22.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-cobertura-3.1.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-0.6.12806-universal-darwin/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-0.6.12806/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-and-runtime-0.6.12806/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-0.6.12815-universal-darwin/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-0.6.12815/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-and-runtime-0.6.12815/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/thor-1.4.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/spoom-1.7.10/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/stackprof-0.2.27")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/stackprof-0.2.27/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/yard-0.9.37/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/yard-sorbet-0.9.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/tapioca-0.17.9/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/test-prof-1.4.4/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/test-prof-1.5.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/vernier-1.9.0")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/vernier-1.9.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/warning-1.5.0/lib")
Loading