Skip to content

Commit

Permalink
Merge pull request #16341 from issyl0/rubocop-ruby-3.1
Browse files Browse the repository at this point in the history
rubocop: Set TargetRubyVersion to 3.1 & disable all cops that fail
  • Loading branch information
MikeMcQuaid authored Dec 15, 2023
2 parents e269d27 + de592af commit dc3daf7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
25 changes: 22 additions & 3 deletions Library/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inherit_mode:
- Exclude

AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 3.1
ActiveSupportExtensionsEnabled: true
NewCops: enable
Include:
Expand Down Expand Up @@ -386,9 +386,10 @@ Style/InvertibleUnlessCondition:
# Don't require non-standard `exclude?` (for now at least) - it's not available in every file
# :include?:

# would rather freeze too much than too little
# TODO: Enable this cop again once https://github.com/Homebrew/brew/pull/16337#issuecomment-1855668516 is done.
# From the RuboCop docs: "NOTE: Regexp and Range literals are frozen objects since Ruby 3.0."
Style/MutableConstant:
EnforcedStyle: strict
Enabled: false

# Zero-prefixed octal literals are widely used and understood.
Style/NumericLiteralPrefix:
Expand Down Expand Up @@ -469,3 +470,21 @@ Style/UnlessLogicalOperators:
# a bit confusing to non-Rubyists but useful for longer arrays
Style/WordArray:
MinSize: 4

# TODO: Enable these cops once https://github.com/Homebrew/brew/pull/16337#issuecomment-1855668516 is done.
Lint/RedundantDirGlobSort:
Enabled: false
Naming/BlockForwarding:
Enabled: false
Performance/BindCall:
Enabled: false
Performance/MapCompact:
Enabled: false
Style/ArgumentsForwarding:
Enabled: false
Style/ArrayIntersect:
Enabled: false
Style/HashSyntax:
EnforcedShorthandSyntax: either
Style/RedundantFreeze:
Enabled: false
3 changes: 0 additions & 3 deletions Library/Homebrew/PATH.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ class PATH

delegate each: :@paths

# FIXME: Enable cop again when https://github.com/sorbet/sorbet/issues/3532 is fixed.
# rubocop:disable Style/MutableConstant
Element = T.type_alias { T.nilable(T.any(Pathname, String, PATH)) }
private_constant :Element
Elements = T.type_alias { T.any(Element, T::Array[Element]) }
private_constant :Elements
# rubocop:enable Style/MutableConstant

sig { params(paths: Elements).void }
def initialize(*paths)
Expand Down
3 changes: 0 additions & 3 deletions Library/Homebrew/cask/staged.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ module Cask
#
# @api private
module Staged
# FIXME: Enable cop again when https://github.com/sorbet/sorbet/issues/3532 is fixed.
# rubocop:disable Style/MutableConstant
Paths = T.type_alias { T.any(String, Pathname, T::Array[T.any(String, Pathname)]) }
# rubocop:enable Style/MutableConstant

sig { params(paths: Paths, permissions_str: String).void }
def set_permissions(paths, permissions_str)
Expand Down
3 changes: 0 additions & 3 deletions Library/Homebrew/extend/blank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,9 @@ def present? # :nodoc:

class String
BLANK_RE = /\A[[:space:]]*\z/.freeze
# This is a cache that is intentionally mutable
# rubocop:disable Style/MutableConstant
ENCODED_BLANKS_ = T.let(Hash.new do |h, enc|
h[enc] = Regexp.new(BLANK_RE.source.encode(enc), BLANK_RE.options | Regexp::FIXEDENCODING)
end, T::Hash[Encoding, Regexp])
# rubocop:enable Style/MutableConstant

# A string is blank if it's empty or contains whitespaces only:
#
Expand Down
3 changes: 0 additions & 3 deletions Library/Homebrew/github_runner_matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
require "github_runner"

class GitHubRunnerMatrix
# FIXME: Enable cop again when https://github.com/sorbet/sorbet/issues/3532 is fixed.
# rubocop:disable Style/MutableConstant
RunnerSpec = T.type_alias { T.any(LinuxRunnerSpec, MacOSRunnerSpec) }
private_constant :RunnerSpec

Expand All @@ -27,7 +25,6 @@ class GitHubRunnerMatrix

RunnerSpecHash = T.type_alias { T.any(LinuxRunnerSpecHash, MacOSRunnerSpecHash) }
private_constant :RunnerSpecHash
# rubocop:enable Style/MutableConstant

sig { returns(T::Array[GitHubRunner]) }
attr_reader :runners
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/macos_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class << self
end

module MacOSVersions
SYMBOLS = LazyObject.new do # rubocop:disable Style/MutableConstant
SYMBOLS = LazyObject.new do
odisabled "MacOSVersions::SYMBOLS", "MacOSVersion::SYMBOLS"
MacOSVersion::SYMBOLS
end
Expand All @@ -168,7 +168,7 @@ module MacOSVersions
module OS
module Mac
# TODO: Replace `::Version` with `Version` when this is removed.
Version = LazyObject.new do # rubocop:disable Style/MutableConstant
Version = LazyObject.new do
odisabled "OS::Mac::Version", "MacOSVersion"
MacOSVersion
end
Expand Down

0 comments on commit dc3daf7

Please sign in to comment.