Skip to content

Commit

Permalink
Merge pull request #11939 from FnControlRuby/def_node_matcher
Browse files Browse the repository at this point in the history
Use unification to match `File.open` block param with `#read` receiver
  • Loading branch information
koic committed Jun 8, 2023
2 parents 13a39cc + c2e024b commit 01b5714
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rubocop/cop/style/file_read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class FileRead < Base

# @!method block_read?(node)
def_node_matcher :block_read?, <<~PATTERN
(block _ (args (arg $_)) (send (lvar $_) :read))
(block _ (args (arg _name)) (send (lvar _name) :read))
PATTERN

def on_send(node)
Expand Down Expand Up @@ -100,7 +100,7 @@ def read_node?(node, block_pass)
def file_open_read?(node)
return true if send_read?(node)

block_read?(node) { |block_arg, read_lvar| block_arg == read_lvar }
block_read?(node)
end

def read_method(mode)
Expand Down

0 comments on commit 01b5714

Please sign in to comment.