Skip to content

Commit 6b12af3

Browse files
authored
Merge pull request #20969 from Homebrew/dug-target-ruby-version
Bump rubocop TargetRubyVersion
2 parents c1f0e7e + 47636bc commit 6b12af3

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Library/.rubocop.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ inherit_mode:
1818
- Exclude
1919

2020
AllCops:
21-
# TODO: This is the default parser in Ruby >= 3.4
22-
# https://github.com/rubocop/rubocop-ast/blob/6b9136235219e9448ee4f369e17cf69bcd9db621/lib/rubocop/ast/processed_source.rb#L385
23-
ParserEngine: parser_prism
24-
TargetRubyVersion: 3.3
21+
TargetRubyVersion: 3.4
2522
NewCops: enable
2623
Include:
2724
- "**/*.rbi"
@@ -412,6 +409,10 @@ Style/InvertibleUnlessCondition:
412409
:zero?:
413410
:blank?: :present?
414411

412+
# Reconsider once sorbet supports "it": https://github.com/sorbet/sorbet/issues/8375
413+
Style/ItBlockParameter:
414+
Enabled: false
415+
415416
Style/MutableConstant:
416417
# would rather freeze too much than too little
417418
EnforcedStyle: strict

Library/Homebrew/test/rubocop_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require "open3"
4+
require "yaml"
45

56
RSpec.describe "RuboCop" do
67
context "when calling `rubocop` outside of the Homebrew environment" do
@@ -23,4 +24,17 @@
2324
expect(status).to be_a_success
2425
end
2526
end
27+
28+
context "with TargetRubyVersion" do
29+
it "matches .ruby-version" do
30+
rubocop_config_path = HOMEBREW_LIBRARY_PATH.parent/".rubocop.yml"
31+
rubocop_config = YAML.unsafe_load_file(rubocop_config_path)
32+
target_ruby_version = rubocop_config.dig("AllCops", "TargetRubyVersion")
33+
34+
ruby_version_path = HOMEBREW_LIBRARY_PATH/".ruby-version"
35+
ruby_version = ruby_version_path.read.strip.to_f
36+
37+
expect(target_ruby_version).to eq(ruby_version)
38+
end
39+
end
2640
end

0 commit comments

Comments
 (0)