diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 66c08e5248..ea8067d398 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -406,6 +406,12 @@ Style/OpenStructUse: - "Homebrew/cli/args.rb" - "Homebrew/cli/args.rbi" +Style/OptionalBooleanParameter: + AllowedMethods: + # This is an override of a core library method + # see https://ruby-doc.org/3.3.4/Object.html#method-i-respond_to-3F + - respond_to? + # Rescuing `StandardError` is an understood default. Style/RescueStandardError: EnforcedStyle: implicit diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index beb92b2c5b..067acba83f 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -734,7 +734,7 @@ class Version def to_json(*options) = version.to_json(*options) sig { params(method: T.any(Symbol, String), include_all: T::Boolean).returns(T::Boolean) } - def respond_to?(method, include_all = false) # rubocop:disable Style/OptionalBooleanParameter (`Object` override) + def respond_to?(method, include_all = false) return !null? if ["to_str", :to_str].include?(method) super