Merge pull request #16673 from dduugg/fix-rubocop-filters

Fix rubocop .rbi exclusion
This commit is contained in:
Mike McQuaid 2024-02-19 14:07:30 +00:00 committed by GitHub
commit b083b1a85b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 35 additions and 135 deletions

View File

@ -15,9 +15,10 @@ AllCops:
TargetRubyVersion: 3.1 TargetRubyVersion: 3.1
NewCops: enable NewCops: enable
Include: Include:
- "**/*.rbi" # FIXME: https://github.com/rubocop/rubocop/issues/12695
- "Homebrew/**/*.rbi"
Exclude: Exclude:
- "Homebrew/sorbet/rbi/gems/**/*.rbi" - "Homebrew/sorbet/rbi/{dsl,gems}/**/*.rbi"
- "Homebrew/bin/*" - "Homebrew/bin/*"
- "Homebrew/vendor/**/*" - "Homebrew/vendor/**/*"
- "Taps/*/*/vendor/**/*" - "Taps/*/*/vendor/**/*"
@ -259,6 +260,10 @@ Sorbet/ConstantsFromStrings:
Sorbet/FalseSigil: Sorbet/FalseSigil:
Enabled: false Enabled: false
# We generally prefer to colo rbi files with the Ruby files they describe.
Sorbet/ForbidRBIOutsideOfAllowedPaths:
Enabled: false
# T::Sig is monkey-patched into Module # T::Sig is monkey-patched into Module
Sorbet/RedundantExtendTSig: Sorbet/RedundantExtendTSig:
Enabled: true Enabled: true
@ -295,6 +300,10 @@ Style/BlockDelimiters:
BracesRequiredMethods: BracesRequiredMethods:
- "sig" - "sig"
Style/ClassAndModuleChildren:
Exclude:
- "**/*.rbi"
# Use consistent style for better readability. # Use consistent style for better readability.
Style/CollectionMethods: Style/CollectionMethods:
Enabled: true Enabled: true
@ -382,6 +391,7 @@ Style/OpenStructUse:
# TODO: This is a pre-existing violation and should be corrected # TODO: This is a pre-existing violation and should be corrected
# to define methods so that call sites can be type-checked. # to define methods so that call sites can be type-checked.
- "Homebrew/cli/args.rb" - "Homebrew/cli/args.rb"
- "Homebrew/cli/args.rbi"
# Rescuing `StandardError` is an understood default. # Rescuing `StandardError` is an understood default.
Style/RescueStandardError: Style/RescueStandardError:

View File

@ -321,7 +321,7 @@ module Homebrew
sig { returns(T.nilable(String)) } sig { returns(T.nilable(String)) }
def screen_saverdir; end def screen_saverdir; end
sig { returns(T::Array[String])} sig { returns(T::Array[String]) }
def repositories; end def repositories; end
sig { returns(T.nilable(String)) } sig { returns(T.nilable(String)) }

View File

@ -4,8 +4,8 @@ class Dependencies < SimpleDelegator
include Kernel include Kernel
# This is a workaround to enable `alias eql? ==` # This is a workaround to enable `alias eql? ==`
# @see https://github.com/sorbet/sorbet/issues/2378#issuecomment-569474238 # @see https://github.com/sorbet/sorbet/issues/2378#issuecomment-569474238
sig { params(arg0: BasicObject).returns(T::Boolean) } sig { params(other: BasicObject).returns(T::Boolean) }
def ==(arg0); end def ==(other); end
end end
class Requirements < SimpleDelegator class Requirements < SimpleDelegator

View File

@ -4,15 +4,20 @@ module AbstractDownloadStrategy::Pourable
requires_ancestor { AbstractDownloadStrategy } requires_ancestor { AbstractDownloadStrategy }
end end
# This is a third-party implementation
# rubocop:disable Lint/StructNewOverride
class Mechanize::HTTP class Mechanize::HTTP
ContentDisposition = Struct.new :type, :filename, :creation_date, ContentDisposition = Struct.new :type, :filename, :creation_date,
:modification_date, :read_date, :size, :parameters :modification_date, :read_date, :size, :parameters
end end
# rubocop:enable Lint/StructNewOverride
# rubocop:disable Style/OptionalBooleanParameter
class Mechanize::HTTP::ContentDispositionParser class Mechanize::HTTP::ContentDispositionParser
sig { sig {
params(content_disposition: String, header: T::Boolean) params(content_disposition: String, header: T::Boolean)
.returns(T.nilable(Mechanize::HTTP::ContentDisposition)) .returns(T.nilable(Mechanize::HTTP::ContentDisposition))
} }
def parse(content_disposition, header = false); end def parse(content_disposition, header = false); end
end end
# rubocop:enable Style/OptionalBooleanParameter

View File

@ -2,19 +2,19 @@
# frozen_string_literal: true # frozen_string_literal: true
class Hash class Hash
sig do sig {
type_parameters(:k2).params( type_parameters(:k2).params(
other_hash: T::Hash[T.type_parameter(:k2), T.untyped], other_hash: T::Hash[T.type_parameter(:k2), T.untyped],
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)) block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)),
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped]) ).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped])
end }
def deep_merge(other_hash, &block); end def deep_merge(other_hash, &block); end
sig do sig {
type_parameters(:k2).params( type_parameters(:k2).params(
other_hash: T::Hash[T.type_parameter(:k2), T.untyped], other_hash: T::Hash[T.type_parameter(:k2), T.untyped],
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)) block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)),
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped]) ).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped])
end }
def deep_merge!(other_hash, &block); end def deep_merge!(other_hash, &block); end
end end

View File

@ -3,14 +3,14 @@
class Hash class Hash
sig { sig {
type_parameters(:out).params( type_parameters(:out).params(
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)) block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)),
).returns(T::Hash[Hash::K, T.type_parameter(:out)]) ).returns(T::Hash[Hash::K, T.type_parameter(:out)])
} }
def deep_transform_values(&block); end def deep_transform_values(&block); end
sig { sig {
type_parameters(:out).params( type_parameters(:out).params(
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)) block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)),
).returns(T::Hash[Hash::K, T.type_parameter(:out)]) ).returns(T::Hash[Hash::K, T.type_parameter(:out)])
} }
def deep_transform_values!(&block); end def deep_transform_values!(&block); end

View File

@ -4,14 +4,14 @@
class Hash class Hash
sig { sig {
type_parameters(:out).params( type_parameters(:out).params(
block: T.proc.params(o: K).returns(T.type_parameter(:out)) block: T.proc.params(o: K).returns(T.type_parameter(:out)),
).returns(T::Hash[T.type_parameter(:out), V]) ).returns(T::Hash[T.type_parameter(:out), V])
} }
def deep_transform_keys(&block); end def deep_transform_keys(&block); end
sig { sig {
type_parameters(:out).params( type_parameters(:out).params(
block: T.proc.params(o: K).returns(T.type_parameter(:out)) block: T.proc.params(o: K).returns(T.type_parameter(:out)),
).returns(T::Hash[T.type_parameter(:out), V]) ).returns(T::Hash[T.type_parameter(:out), V])
} }
def deep_transform_keys!(&block); end def deep_transform_keys!(&block); end

View File

@ -3,6 +3,6 @@
class PkgVersion class PkgVersion
# This is a workaround to enable `alias eql? ==` # This is a workaround to enable `alias eql? ==`
# @see https://github.com/sorbet/sorbet/issues/2378#issuecomment-569474238 # @see https://github.com/sorbet/sorbet/issues/2378#issuecomment-569474238
sig { params(arg0: BasicObject).returns(T::Boolean) } sig { params(other: BasicObject).returns(T::Boolean) }
def ==(arg0); end def ==(other); end
end end

View File

@ -1,4 +1,5 @@
# typed: strict # typed: strict
class PATH class PATH
sig { params(args: T.untyped, options: T.untyped, block: T.untyped).returns(T.untyped) } sig { params(args: T.untyped, options: T.untyped, block: T.untyped).returns(T.untyped) }
def each(*args, **options, &block); end def each(*args, **options, &block); end

View File

@ -3,14 +3,6 @@
# This file contains temporary definitions for fixes that have # This file contains temporary definitions for fixes that have
# been submitted upstream to https://github.com/sorbet/sorbet. # been submitted upstream to https://github.com/sorbet/sorbet.
# https://github.com/sorbet/sorbet/pull/7682
class Array
include JSON::Ext::Generator::GeneratorMethods::Array
end
class Hash
include JSON::Ext::Generator::GeneratorMethods::Hash
end
# https://github.com/sorbet/sorbet/pull/7650 # https://github.com/sorbet/sorbet/pull/7650
class Etc::Group < Struct class Etc::Group < Struct
sig { returns(Integer) } sig { returns(Integer) }
@ -28,111 +20,3 @@ module IRB
sig { params(ap_path: T.nilable(String), argv: T::Array[String]).void } sig { params(ap_path: T.nilable(String), argv: T::Array[String]).void }
def self.setup(ap_path, argv: ::ARGV); end def self.setup(ap_path, argv: ::ARGV); end
end end
# https://github.com/sorbet/sorbet/pull/7678
class String
sig do
params(
arg0: Integer,
arg1: Integer,
)
.returns(T.nilable(String))
end
sig do
params(
arg0: T.any(T::Range[Integer], Regexp),
)
.returns(T.nilable(String))
end
sig do
params(
arg0: Regexp,
arg1: Integer,
)
.returns(T.nilable(String))
end
sig do
params(
arg0: Regexp,
arg1: T.any(String, Symbol),
)
.returns(T.nilable(String))
end
sig do
params(
arg0: String,
)
.returns(T.nilable(String))
end
def [](arg0, arg1=T.unsafe(nil)); end
sig do
params(
arg0: Integer,
arg1: Integer,
)
.returns(T.nilable(String))
end
sig do
params(
arg0: T.any(T::Range[Integer], Regexp),
)
.returns(T.nilable(String))
end
sig do
params(
arg0: Regexp,
arg1: Integer,
)
.returns(T.nilable(String))
end
sig do
params(
arg0: Regexp,
arg1: T.any(String, Symbol),
)
.returns(T.nilable(String))
end
sig do
params(
arg0: String,
)
.returns(T.nilable(String))
end
def slice!(arg0, arg1=T.unsafe(nil)); end
sig do
params(
arg0: Integer,
arg1: Integer,
)
.returns(T.nilable(String))
end
sig do
params(
arg0: T.any(T::Range[Integer], Regexp),
)
.returns(T.nilable(String))
end
sig do
params(
arg0: Regexp,
arg1: Integer,
)
.returns(T.nilable(String))
end
sig do
params(
arg0: Regexp,
arg1: T.any(String, Symbol),
)
.returns(T.nilable(String))
end
sig do
params(
arg0: String,
)
.returns(T.nilable(String))
end
def slice(arg0, arg1=T.unsafe(nil)); end
end