Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rubocop .rbi exclusion #16673

Merged
merged 6 commits into from Feb 19, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions Library/.rubocop.yml
Expand Up @@ -15,9 +15,10 @@ AllCops:
TargetRubyVersion: 3.1
NewCops: enable
Include:
- "**/*.rbi"
# FIXME: https://github.com/rubocop/rubocop/issues/12695
- "Homebrew/**/*.rbi"
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved
Exclude:
- "Homebrew/sorbet/rbi/gems/**/*.rbi"
- "Homebrew/sorbet/rbi/{dsl,gems}/**/*.rbi"
- "Homebrew/bin/*"
- "Homebrew/vendor/**/*"
- "Taps/*/*/vendor/**/*"
Expand Down Expand Up @@ -259,6 +260,10 @@ Sorbet/ConstantsFromStrings:
Sorbet/FalseSigil:
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
Sorbet/RedundantExtendTSig:
Enabled: true
Expand Down Expand Up @@ -295,6 +300,10 @@ Style/BlockDelimiters:
BracesRequiredMethods:
- "sig"

Style/ClassAndModuleChildren:
Exclude:
- "**/*.rbi"

# Use consistent style for better readability.
Style/CollectionMethods:
Enabled: true
Expand Down Expand Up @@ -382,6 +391,7 @@ Style/OpenStructUse:
# TODO: This is a pre-existing violation and should be corrected
# to define methods so that call sites can be type-checked.
- "Homebrew/cli/args.rb"
- "Homebrew/cli/args.rbi"

# Rescuing `StandardError` is an understood default.
Style/RescueStandardError:
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cli/args.rbi
Expand Up @@ -321,7 +321,7 @@ module Homebrew
sig { returns(T.nilable(String)) }
def screen_saverdir; end

sig { returns(T::Array[String])}
sig { returns(T::Array[String]) }
def repositories; end

sig { returns(T.nilable(String)) }
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/dependencies.rbi
Expand Up @@ -4,8 +4,8 @@ class Dependencies < SimpleDelegator
include Kernel
# This is a workaround to enable `alias eql? ==`
# @see https://github.com/sorbet/sorbet/issues/2378#issuecomment-569474238
sig { params(arg0: BasicObject).returns(T::Boolean) }
def ==(arg0); end
sig { params(other: BasicObject).returns(T::Boolean) }
def ==(other); end
end

class Requirements < SimpleDelegator
Expand Down
9 changes: 7 additions & 2 deletions Library/Homebrew/download_strategy.rbi
Expand Up @@ -4,15 +4,20 @@ module AbstractDownloadStrategy::Pourable
requires_ancestor { AbstractDownloadStrategy }
end

# This is a third-party implementation
# rubocop:disable Lint/StructNewOverride
class Mechanize::HTTP
ContentDisposition = Struct.new :type, :filename, :creation_date,
:modification_date, :read_date, :size, :parameters
:modification_date, :read_date, :size, :parameters
end
# rubocop:enable Lint/StructNewOverride

# rubocop:disable Style/OptionalBooleanParameter
class Mechanize::HTTP::ContentDispositionParser
sig {
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
end
# rubocop:enable Style/OptionalBooleanParameter
12 changes: 6 additions & 6 deletions Library/Homebrew/extend/hash/deep_merge.rbi
Expand Up @@ -2,19 +2,19 @@
# frozen_string_literal: true

class Hash
sig do
sig {
type_parameters(:k2).params(
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])
end
}
def deep_merge(other_hash, &block); end

sig do
sig {
type_parameters(:k2).params(
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])
end
}
def deep_merge!(other_hash, &block); end
end
4 changes: 2 additions & 2 deletions Library/Homebrew/extend/hash/deep_transform_values.rbi
Expand Up @@ -3,14 +3,14 @@
class Hash
sig {
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)])
}
def deep_transform_values(&block); end

sig {
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)])
}
def deep_transform_values!(&block); end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/extend/hash/keys.rbi
Expand Up @@ -4,14 +4,14 @@
class Hash
sig {
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])
}
def deep_transform_keys(&block); end

sig {
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])
}
def deep_transform_keys!(&block); end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/pkg_version.rbi
Expand Up @@ -3,6 +3,6 @@
class PkgVersion
# This is a workaround to enable `alias eql? ==`
# @see https://github.com/sorbet/sorbet/issues/2378#issuecomment-569474238
sig { params(arg0: BasicObject).returns(T::Boolean) }
def ==(arg0); end
sig { params(other: BasicObject).returns(T::Boolean) }
def ==(other); end
end
1 change: 1 addition & 0 deletions Library/Homebrew/sorbet/rbi/parlour.rbi
@@ -1,4 +1,5 @@
# typed: strict

class PATH
sig { params(args: T.untyped, options: T.untyped, block: T.untyped).returns(T.untyped) }
def each(*args, **options, &block); end
Expand Down
116 changes: 0 additions & 116 deletions Library/Homebrew/sorbet/rbi/upstream.rbi
Expand Up @@ -3,14 +3,6 @@
# This file contains temporary definitions for fixes that have
# 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
class Etc::Group < Struct
sig { returns(Integer) }
Expand All @@ -28,111 +20,3 @@ module IRB
sig { params(ap_path: T.nilable(String), argv: T::Array[String]).void }
def self.setup(ap_path, argv: ::ARGV); 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