Skip to content

Commit

Permalink
Code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dduugg committed Feb 10, 2024
1 parent 9ee4daa commit 9d7cdc0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
16 changes: 8 additions & 8 deletions Library/Homebrew/rubocops/cask/extend/node.rbi
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# typed: strict

class RuboCop::AST::Node
sig { returns(T::Boolean) }
def arch_variable?; end

sig { returns(T::Boolean) }
def begin_block?; end
sig { returns(T.nilable(RuboCop::AST::SendNode)) }
def method_node; end

sig { returns(T.nilable(RuboCop::AST::Node)) }
def block_body; end

sig { returns(T::Boolean) }
def cask_block?; end

sig { returns(T.nilable(RuboCop::AST::Node)) }
def method_node; end

sig { returns(T::Boolean) }
def on_system_block?; end

sig { returns(T::Boolean) }
def arch_variable?; end

sig { returns(T::Boolean) }
def begin_block?; end
end
4 changes: 2 additions & 2 deletions Library/Homebrew/sorbet/rbi/gems/[email protected]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Library/Homebrew/sorbet/tapioca/compilers/rubocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def self.gather_constants
# exclude vendored code, to avoid contradicting their RBI files
!path.include?("/vendor/bundle/ruby/") &&
# exclude source code that already has an RBI file
!Pathname("#{path}i").exist? &&
!File.exist?("#{path}i") &&
# exclude source code that doesn't use the DSLs
File.readlines(path).grep(/def_node_/).any?
File.readlines(path).any?(/def_node_/)
end
end

Expand All @@ -40,18 +40,19 @@ def decorate
# https://github.com/rubocop/rubocop-ast/blob/master/lib/rubocop/ast/node_pattern.rb
# https://github.com/rubocop/rubocop-ast/blob/master/lib/rubocop/ast/node_pattern/method_definer.rb
# The type signatures below could maybe be stronger, but I only wanted to avoid errors:
if source.start_with?("def_node_matcher")
case source
when /\Adef_node_matcher/
# https://github.com/Shopify/tapioca/blob/3341a9b/lib/tapioca/rbi_ext/model.rb#L89
klass.create_method(
method_name.to_s,
parameters: [
parameters: [
create_rest_param("node", type: "RuboCop::AST::Node"),
create_kw_rest_param("kwargs", type: "T.untyped"),
create_block_param("block", type: "T.untyped"),
],
return_type: "T.untyped",
)
elsif source.start_with?("def_node_search")
when /\Adef_node_search/
klass.create_method(
method_name.to_s,
parameters: [
Expand Down

0 comments on commit 9d7cdc0

Please sign in to comment.