Merge pull request #20193 from Homebrew/skinny-rubocop-rbi

Keep only the parts of `rubocop.rbi` that we actually use
This commit is contained in:
Mike McQuaid 2025-07-07 16:59:45 +00:00 committed by GitHub
commit 5ec756e0ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 352 additions and 55054 deletions

View File

@ -68,6 +68,9 @@ module Homebrew
ohai "Updating Tapioca RBI files..." ohai "Updating Tapioca RBI files..."
safe_system "bundle", "exec", "tapioca", "gem", *tapioca_args safe_system "bundle", "exec", "tapioca", "gem", *tapioca_args
ohai "Trimming RuboCop RBI because by default it's massive..."
trim_rubocop_rbi
if args.suggest_typed? if args.suggest_typed?
ohai "Checking if we can bump Sorbet `typed` sigils..." ohai "Checking if we can bump Sorbet `typed` sigils..."
# --sorbet needed because of https://github.com/Shopify/spoom/issues/488 # --sorbet needed because of https://github.com/Shopify/spoom/issues/488
@ -116,6 +119,157 @@ module Homebrew
Homebrew.failed = true Homebrew.failed = true
end end
end end
sig { params(path: T.any(String, Pathname)).void }
def trim_rubocop_rbi(path: HOMEBREW_LIBRARY_PATH/"sorbet/rbi/gems/rubocop@*.rbi")
rbi_file = Dir.glob(path).first
return unless rbi_file.present?
return unless (rbi_path = Pathname.new(rbi_file)).exist?
require "prism"
original_content = rbi_path.read
parsed = Prism.parse(original_content)
return unless parsed.success?
allowlist = %w[
Parser::Source
RuboCop::AST::Node
RuboCop::AST::NodePattern
RuboCop::AST::ProcessedSource
RuboCop::CLI
RuboCop::Config
RuboCop::Cop::AllowedPattern
RuboCop::Cop::AllowedMethods
RuboCop::Cop::AutoCorrector
RuboCop::Cop::AutocorrectLogic
RuboCop::Cop::Base
RuboCop::Cop::CommentsHelp
RuboCop::Cop::ConfigurableFormatting
RuboCop::Cop::ConfigurableNaming
RuboCop::Cop::Corrector
RuboCop::Cop::IgnoredMethods
RuboCop::Cop::IgnoredNode
RuboCop::Cop::IgnoredPattern
RuboCop::Cop::MethodPreference
RuboCop::Cop::Offense
RuboCop::Cop::RangeHelp
RuboCop::Cop::Registry
RuboCop::Cop::Util
RuboCop::DirectiveComment
RuboCop::Error
RuboCop::ExcludeLimit
RuboCop::Ext::Comment
RuboCop::Ext::ProcessedSource
RuboCop::Ext::Range
RuboCop::FileFinder
RuboCop::Formatter::TextUtil
RuboCop::Formatter::PathUtil
RuboCop::Options
RuboCop::ResultCache
RuboCop::Runner
RuboCop::TargetFinder
RuboCop::Version
].freeze
nodes_to_keep = Set.new
parsed.value.statements.body.each do |node|
case node
when Prism::ModuleNode, Prism::ClassNode
# Keep if it's in our allowlist or is a top-level essential node.
full_name = extract_full_name(node)
nodes_to_keep << node if full_name.blank? || allowlist.any? { |name| full_name.start_with?(name) }
when Prism::ConstantWriteNode # Keep essential constants.
nodes_to_keep << node if node.name.to_s.match?(/^[[:digit:][:upper:]_]+$/)
else # Keep other top-level nodes (comments, etc.)
nodes_to_keep << node
end
end
new_content = generate_trimmed_rbi(original_content, nodes_to_keep, parsed)
rbi_path.write(new_content)
end
private
sig { params(node: Prism::Node).returns(String) }
def extract_full_name(node)
case node
when Prism::ModuleNode, Prism::ClassNode
parts = []
constant_path = node.constant_path
if constant_path.is_a?(Prism::ConstantReadNode)
parts << constant_path.name.to_s
elsif constant_path.is_a?(Prism::ConstantPathNode)
parts.concat(extract_constant_path_parts(constant_path))
end
parts.join("::")
else
""
end
end
sig { params(constant_path: T.any(Prism::ConstantPathNode, Prism::Node)).returns(T::Array[String]) }
def extract_constant_path_parts(constant_path)
parts = []
current = T.let(constant_path, T.nilable(Prism::Node))
while current
case current
when Prism::ConstantPathNode
parts.unshift(current.name.to_s)
current = current.parent
when Prism::ConstantReadNode
parts.unshift(current.name.to_s)
break
else
break
end
end
parts
end
sig {
params(
original_content: String,
nodes_to_keep: T::Set[Prism::Node],
parsed: Prism::ParseResult,
).returns(String)
}
def generate_trimmed_rbi(original_content, nodes_to_keep, parsed)
lines = original_content.lines
output_lines = []
first_node = parsed.value.statements.body.first
if first_node
first_line = first_node.location.start_line - 1
(0...first_line).each { |i| output_lines << lines[i] if lines[i] }
end
parsed.value.statements.body.each do |node|
next unless nodes_to_keep.include?(node)
start_line = node.location.start_line - 1
end_line = node.location.end_line - 1
(start_line..end_line).each { |i| output_lines << lines[i] if lines[i] }
output_lines << "\n"
end
header = <<~EOS.chomp
# typed: true
# This file is autogenerated. Do not edit it by hand.
# To regenerate, run `brew typecheck --update rubocop`.
EOS
return header if output_lines.empty?
output_lines.join
end
end end
end end
end end

View File

@ -7508,28 +7508,28 @@ class RuboCop::AST::YieldNode < ::RuboCop::AST::Node
end end
class RuboCop::CommentConfig class RuboCop::CommentConfig
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#34 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#34
def initialize(processed_source); end def initialize(processed_source); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#63 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#63
def comment_only_line?(line_number); end def comment_only_line?(line_number); end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def config(*_arg0, **_arg1, &_arg2); end def config(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#51 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#51
def cop_disabled_line_ranges; end def cop_disabled_line_ranges; end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#39 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#39
def cop_enabled_at_line?(cop, line_number); end def cop_enabled_at_line?(cop, line_number); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#47 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#47
def cop_opted_in?(cop); end def cop_opted_in?(cop); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#55 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#55
def extra_enabled_comments; end def extra_enabled_comments; end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#30 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#30
def processed_source; end def processed_source; end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
@ -7537,51 +7537,51 @@ class RuboCop::CommentConfig
private private
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#96 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#96
def analyze; end def analyze; end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#124 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#124
def analyze_cop(analysis, directive); end def analyze_cop(analysis, directive); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#144 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#144
def analyze_disabled(analysis, directive); end def analyze_disabled(analysis, directive); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#155 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#155
def analyze_rest(analysis, directive); end def analyze_rest(analysis, directive); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#135 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#135
def analyze_single_line(analysis, directive); end def analyze_single_line(analysis, directive); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#164 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#164
def cop_line_ranges(analysis); end def cop_line_ranges(analysis); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#170 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#170
def each_directive; end def each_directive; end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#69 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#69
def extra_enabled_comments_with_names(extras:, names:); end def extra_enabled_comments_with_names(extras:, names:); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#190 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#190
def handle_enable_all(directive, names, extras); end def handle_enable_all(directive, names, extras); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#204 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#204
def handle_switch(directive, names, extras); end def handle_switch(directive, names, extras); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#115 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#115
def inject_disabled_cops_directives(analyses); end def inject_disabled_cops_directives(analyses); end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#183 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#183
def non_comment_token_line_numbers; end def non_comment_token_line_numbers; end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#83 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#83
def opt_in_cops; end def opt_in_cops; end
# source://rubocop/1.75.2/lib/rubocop/comment_config.rb#179 # source://rubocop/1.75.6/lib/rubocop/comment_config.rb#179
def qualified_cop_name(cop_name); end def qualified_cop_name(cop_name); end
end end
class RuboCop::Config class RuboCop::Config
# source://rubocop/1.75.2/lib/rubocop/config.rb#31 # source://rubocop/1.75.6/lib/rubocop/config.rb#31
def initialize(hash = T.unsafe(nil), loaded_path = T.unsafe(nil)); end def initialize(hash = T.unsafe(nil), loaded_path = T.unsafe(nil)); end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
@ -7590,40 +7590,40 @@ class RuboCop::Config
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def []=(*_arg0, **_arg1, &_arg2); end def []=(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#212 # source://rubocop/1.75.6/lib/rubocop/config.rb#212
def active_support_extensions_enabled?; end def active_support_extensions_enabled?; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#127 # source://rubocop/1.75.6/lib/rubocop/config.rb#127
def add_excludes_from_higher_level(highest_config); end def add_excludes_from_higher_level(highest_config); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#239 # source://rubocop/1.75.6/lib/rubocop/config.rb#239
def allowed_camel_case_file?(file); end def allowed_camel_case_file?(file); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#283 # source://rubocop/1.75.6/lib/rubocop/config.rb#283
def base_dir_for_path_parameters; end def base_dir_for_path_parameters; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#313 # source://rubocop/1.75.6/lib/rubocop/config.rb#313
def bundler_lock_file_path; end def bundler_lock_file_path; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#85 # source://rubocop/1.75.6/lib/rubocop/config.rb#85
def check; end def check; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#180 # source://rubocop/1.75.6/lib/rubocop/config.rb#180
def clusivity_config_for_badge?(badge); end def clusivity_config_for_badge?(badge); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#200 # source://rubocop/1.75.6/lib/rubocop/config.rb#200
def cop_enabled?(name); end def cop_enabled?(name); end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def delete(*_arg0, **_arg1, &_arg2); end def delete(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#139 # source://rubocop/1.75.6/lib/rubocop/config.rb#139
def deprecation_check; end def deprecation_check; end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def dig(*_arg0, **_arg1, &_arg2); end def dig(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#204 # source://rubocop/1.75.6/lib/rubocop/config.rb#204
def disabled_new_cops?; end def disabled_new_cops?; end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
@ -7632,40 +7632,40 @@ class RuboCop::Config
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def each_key(*_arg0, **_arg1, &_arg2); end def each_key(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#208 # source://rubocop/1.75.6/lib/rubocop/config.rb#208
def enabled_new_cops?; end def enabled_new_cops?; end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def fetch(*_arg0, **_arg1, &_arg2); end def fetch(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#261 # source://rubocop/1.75.6/lib/rubocop/config.rb#261
def file_to_exclude?(file); end def file_to_exclude?(file); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#220 # source://rubocop/1.75.6/lib/rubocop/config.rb#220
def file_to_include?(file); end def file_to_include?(file); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#196 # source://rubocop/1.75.6/lib/rubocop/config.rb#196
def for_all_cops; end def for_all_cops; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#166 # source://rubocop/1.75.6/lib/rubocop/config.rb#166
def for_badge(badge); end def for_badge(badge); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#153 # source://rubocop/1.75.6/lib/rubocop/config.rb#153
def for_cop(cop); end def for_cop(cop); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#191 # source://rubocop/1.75.6/lib/rubocop/config.rb#191
def for_department(department_name); end def for_department(department_name); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#160 # source://rubocop/1.75.6/lib/rubocop/config.rb#160
def for_enabled_cop(cop); end def for_enabled_cop(cop); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#338 # source://rubocop/1.75.6/lib/rubocop/config.rb#338
def gem_versions_in_target; end def gem_versions_in_target; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#342 # source://rubocop/1.75.6/lib/rubocop/config.rb#342
def inspect; end def inspect; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#110 # source://rubocop/1.75.6/lib/rubocop/config.rb#110
def internal?; end def internal?; end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
@ -7674,16 +7674,16 @@ class RuboCop::Config
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def keys(*_arg0, **_arg1, &_arg2); end def keys(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#81 # source://rubocop/1.75.6/lib/rubocop/config.rb#81
def loaded_features; end def loaded_features; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#21 # source://rubocop/1.75.6/lib/rubocop/config.rb#21
def loaded_path; end def loaded_path; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#77 # source://rubocop/1.75.6/lib/rubocop/config.rb#77
def loaded_plugins; end def loaded_plugins; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#115 # source://rubocop/1.75.6/lib/rubocop/config.rb#115
def make_excludes_absolute; end def make_excludes_absolute; end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
@ -7692,37 +7692,37 @@ class RuboCop::Config
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def merge(*_arg0, **_arg1, &_arg2); end def merge(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#293 # source://rubocop/1.75.6/lib/rubocop/config.rb#293
def parser_engine; end def parser_engine; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#274 # source://rubocop/1.75.6/lib/rubocop/config.rb#274
def path_relative_to_config(path); end def path_relative_to_config(path); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#270 # source://rubocop/1.75.6/lib/rubocop/config.rb#270
def patterns_to_exclude; end def patterns_to_exclude; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#266 # source://rubocop/1.75.6/lib/rubocop/config.rb#266
def patterns_to_include; end def patterns_to_include; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#324 # source://rubocop/1.75.6/lib/rubocop/config.rb#324
def pending_cops; end def pending_cops; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#253 # source://rubocop/1.75.6/lib/rubocop/config.rb#253
def possibly_include_hidden?; end def possibly_include_hidden?; end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def replace(*_arg0, **_arg1, &_arg2); end def replace(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#105 # source://rubocop/1.75.6/lib/rubocop/config.rb#105
def signature; end def signature; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#308 # source://rubocop/1.75.6/lib/rubocop/config.rb#308
def smart_loaded_path; end def smart_loaded_path; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#216 # source://rubocop/1.75.6/lib/rubocop/config.rb#216
def string_literals_frozen_by_default?; end def string_literals_frozen_by_default?; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#297 # source://rubocop/1.75.6/lib/rubocop/config.rb#297
def target_rails_version; end def target_rails_version; end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
@ -7734,7 +7734,7 @@ class RuboCop::Config
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def to_hash(*_arg0, **_arg1, &_arg2); end def to_hash(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#101 # source://rubocop/1.75.6/lib/rubocop/config.rb#101
def to_s; end def to_s; end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
@ -7743,37 +7743,37 @@ class RuboCop::Config
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def validate(*_arg0, **_arg1, &_arg2); end def validate(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#92 # source://rubocop/1.75.6/lib/rubocop/config.rb#92
def validate_after_resolution; end def validate_after_resolution; end
private private
# source://rubocop/1.75.2/lib/rubocop/config.rb#392 # source://rubocop/1.75.6/lib/rubocop/config.rb#392
def department_of(qualified_cop_name); end def department_of(qualified_cop_name); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#380 # source://rubocop/1.75.6/lib/rubocop/config.rb#380
def enable_cop?(qualified_cop_name, cop_options); end def enable_cop?(qualified_cop_name, cop_options); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#367 # source://rubocop/1.75.6/lib/rubocop/config.rb#367
def gem_version_to_major_minor_float(gem_version); end def gem_version_to_major_minor_float(gem_version); end
# source://rubocop/1.75.2/lib/rubocop/config.rb#373 # source://rubocop/1.75.6/lib/rubocop/config.rb#373
def read_gem_versions_from_target_lockfile; end def read_gem_versions_from_target_lockfile; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#354 # source://rubocop/1.75.6/lib/rubocop/config.rb#354
def read_rails_version_from_bundler_lock_file; end def read_rails_version_from_bundler_lock_file; end
# source://rubocop/1.75.2/lib/rubocop/config.rb#349 # source://rubocop/1.75.6/lib/rubocop/config.rb#349
def target_rails_version_from_bundler_lock_file; end def target_rails_version_from_bundler_lock_file; end
class << self class << self
# source://rubocop/1.75.2/lib/rubocop/config.rb#23 # source://rubocop/1.75.6/lib/rubocop/config.rb#23
def create(hash, path, check: T.unsafe(nil)); end def create(hash, path, check: T.unsafe(nil)); end
end end
end end
class RuboCop::ConfigValidator class RuboCop::ConfigValidator
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#28 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#28
def initialize(config); end def initialize(config); end
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
@ -7782,66 +7782,66 @@ class RuboCop::ConfigValidator
# source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19 # source://rubocop-ast//lib/rubocop/ast/utilities/simple_forwardable.rb#19
def smart_loaded_path(*_arg0, **_arg1, &_arg2); end def smart_loaded_path(*_arg0, **_arg1, &_arg2); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#65 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#65
def target_ruby_version; end def target_ruby_version; end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#34 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#34
def validate; end def validate; end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#61 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#61
def validate_after_resolution; end def validate_after_resolution; end
private private
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#100 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#100
def alert_about_unrecognized_cops(invalid_cop_names); end def alert_about_unrecognized_cops(invalid_cop_names); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#264 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#263
def check_cop_config_value(hash, parent = T.unsafe(nil)); end def check_cop_config_value(hash, parent = T.unsafe(nil)); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#73 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#73
def check_obsoletions; end def check_obsoletions; end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#80 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#80
def check_target_ruby; end def check_target_ruby; end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#205 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#205
def each_invalid_parameter(cop_name); end def each_invalid_parameter(cop_name); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#116 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#116
def list_unknown_cops(invalid_cop_names); end def list_unknown_cops(invalid_cop_names); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#284 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#284
def param_error_message(parent, key, value, supposed_values); end def param_error_message(parent, key, value, supposed_values); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#252 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#252
def reject_conflicting_safe_settings; end def reject_conflicting_safe_settings; end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#243 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#243
def reject_mutually_exclusive_defaults; end def reject_mutually_exclusive_defaults; end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#139 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#139
def suggestion(name); end def suggestion(name); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#71 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#71
def target_ruby; end def target_ruby; end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#217 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#217
def validate_enforced_styles(valid_cop_names); end def validate_enforced_styles(valid_cop_names); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#166 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#166
def validate_new_cops_parameter; end def validate_new_cops_parameter; end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#191 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#191
def validate_parameter_names(valid_cop_names); end def validate_parameter_names(valid_cop_names); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#177 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#177
def validate_parameter_shape(valid_cop_names); end def validate_parameter_shape(valid_cop_names); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#237 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#237
def validate_support_and_has_list(name, formats, valid); end def validate_support_and_has_list(name, formats, valid); end
# source://rubocop/1.75.2/lib/rubocop/config_validator.rb#155 # source://rubocop/1.75.6/lib/rubocop/config_validator.rb#155
def validate_syntax_cop; end def validate_syntax_cop; end
end end

View File

@ -4046,7 +4046,7 @@ class RuboCop::Cop::RSpec::MultipleExpectations < ::RuboCop::Cop::RSpec::Base
# source://rubocop-rspec//lib/rubocop/cop/rspec/multiple_expectations.rb#86 # source://rubocop-rspec//lib/rubocop/cop/rspec/multiple_expectations.rb#86
def expect?(param0 = T.unsafe(nil)); end def expect?(param0 = T.unsafe(nil)); end
# source://rubocop/1.75.2/lib/rubocop/cop/exclude_limit.rb#11 # source://rubocop/1.75.6/lib/rubocop/cop/exclude_limit.rb#11
def max=(value); end def max=(value); end
# source://rubocop-rspec//lib/rubocop/cop/rspec/multiple_expectations.rb#93 # source://rubocop-rspec//lib/rubocop/cop/rspec/multiple_expectations.rb#93
@ -4161,7 +4161,7 @@ RuboCop::Cop::RSpec::MultipleExpectations::TRUE_NODE = T.let(T.unsafe(nil), Proc
class RuboCop::Cop::RSpec::MultipleMemoizedHelpers < ::RuboCop::Cop::RSpec::Base class RuboCop::Cop::RSpec::MultipleMemoizedHelpers < ::RuboCop::Cop::RSpec::Base
include ::RuboCop::Cop::RSpec::Variable include ::RuboCop::Cop::RSpec::Variable
# source://rubocop/1.75.2/lib/rubocop/cop/exclude_limit.rb#11 # source://rubocop/1.75.6/lib/rubocop/cop/exclude_limit.rb#11
def max=(value); end def max=(value); end
# source://rubocop-rspec//lib/rubocop/cop/rspec/multiple_memoized_helpers.rb#91 # source://rubocop-rspec//lib/rubocop/cop/rspec/multiple_memoized_helpers.rb#91
@ -4503,7 +4503,7 @@ end
class RuboCop::Cop::RSpec::NestedGroups < ::RuboCop::Cop::RSpec::Base class RuboCop::Cop::RSpec::NestedGroups < ::RuboCop::Cop::RSpec::Base
include ::RuboCop::Cop::RSpec::TopLevelGroup include ::RuboCop::Cop::RSpec::TopLevelGroup
# source://rubocop/1.75.2/lib/rubocop/cop/exclude_limit.rb#11 # source://rubocop/1.75.6/lib/rubocop/cop/exclude_limit.rb#11
def max=(value); end def max=(value); end
# source://rubocop-rspec//lib/rubocop/cop/rspec/nested_groups.rb#107 # source://rubocop-rspec//lib/rubocop/cop/rspec/nested_groups.rb#107

File diff suppressed because it is too large Load Diff

View File

@ -5,4 +5,32 @@ require "dev-cmd/typecheck"
RSpec.describe Homebrew::DevCmd::Typecheck do RSpec.describe Homebrew::DevCmd::Typecheck do
it_behaves_like "parseable arguments" it_behaves_like "parseable arguments"
describe "#trim_rubocop_rbi" do
let(:rbi_file) { Pathname.new("#{TEST_FIXTURE_DIR}/rubocop@x.x.x.rbi") }
let(:typecheck) { described_class.new([]) }
before do
allow(Dir).to receive(:glob).and_return([rbi_file.to_s])
end
it "trims RuboCop RBI file to only include allowlisted classes" do
old_content = rbi_file.read
typecheck.trim_rubocop_rbi(path: rbi_file.to_s)
new_content = rbi_file.read
expect(new_content).to include("RuboCop::Config")
expect(new_content).to include("RuboCop::Cop::Base")
expect(new_content).to include("Parser::Source")
expect(new_content).to include("VERSION")
expect(new_content).to include("SOME_CONSTANT")
expect(new_content).not_to include("SomeUnusedCop")
expect(new_content).not_to include("UnusedModule")
expect(new_content).not_to include("CompletelyUnrelated")
rbi_file.write(old_content)
end
end
end end

View File

@ -0,0 +1,78 @@
# typed: strict
# This file is autogenerated. Do not edit it by hand.
# To regenerate, run `brew typecheck --update rubocop`.
class Parser::Source::Comment
include ::RuboCop::Ext::Comment
end
class Parser::Source::Range
include ::RuboCop::Ext::Range
end
RuboCop::CLI::STATUS_OFFENSES = T.let(T.unsafe(nil), Integer)
RuboCop::CLI::STATUS_SUCCESS = T.let(T.unsafe(nil), Integer)
RuboCop::CommentConfig::CONFIG_DISABLED_LINE_RANGE_MIN = T.let(T.unsafe(nil), Float)
class RuboCop::Config
include ::RuboCop::PathUtil
include ::RuboCop::FileFinder
extend ::RuboCop::SimpleForwardable
# @return [Config] a new instance of Config
#
# source://rubocop//lib/rubocop/config.rb#31
def initialize(hash = T.unsafe(nil), loaded_path = T.unsafe(nil)); end
# source://rubocop-ast/1.44.1/lib/rubocop/ast/utilities/simple_forwardable.rb#19
def [](*_arg0, **_arg1, &_arg2); end
end
RuboCop::Token = RuboCop::AST::Token
class RuboCop::Cop::Base
include ::RuboCop::AST::Sexp
include ::RuboCop::PathUtil
include ::RuboCop::Cop::Util
include ::RuboCop::Cop::IgnoredNode
include ::RuboCop::Cop::AutocorrectLogic
extend ::RuboCop::AST::Sexp
extend ::RuboCop::AST::NodePattern::Macros
extend ::RuboCop::ExcludeLimit
# @return [Base] a new instance of Base
#
# source://rubocop//lib/rubocop/cop/base.rb#156
def initialize(config = T.unsafe(nil), options = T.unsafe(nil)); end
end
class RuboCop::Cop::SomeUnusedCop < RuboCop::Cop::Base
def on_send(_node); end
end
module RuboCop::Cop::UnusedModule; end
class CompletelyUnrelated
def bananas; end
end
module RuboCop::Version
class << self
# @api private
#
# source://rubocop//lib/rubocop/version.rb#121
def config_for_pwd(env); end
# @api private
#
# source://rubocop//lib/rubocop/version.rb#151
def document_version; end
end
end
VERSION = "x.x.x"
SOME_CONSTANT = "some constant value"