Skip to content

Commit

Permalink
Update to use Node#loc?
Browse files Browse the repository at this point in the history
  • Loading branch information
dvandersluis committed Dec 13, 2024
1 parent 619e3f2 commit e853b25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/rubocop/ast/node/if_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def elsif?
#
# @return [Boolean] whether the node has an `else` clause
def else?
loc.respond_to?(:else) && loc.else
loc?(:else)
end

# Checks whether the `if` node is a ternary operator.
#
# @return [Boolean] whether the `if` node is a ternary operator
def ternary?
loc.respond_to?(:question)
loc?(:question)
end

# Returns the keyword of the `if` statement as a string. Returns an empty
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/ast/node/mixin/method_dispatch_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def method_name
#
# @return [Parser::Source::Range] the source range for the method name or keyword
def selector
if loc.respond_to? :keyword
if loc?(:keyword)
loc.keyword
else
loc.selector
Expand Down Expand Up @@ -105,7 +105,7 @@ def command?(name)
#
# @return [Boolean] whether the dispatched method is a setter
def setter_method?
loc.respond_to?(:operator) && loc.operator
loc?(:operator)
end
alias assignment? setter_method?

Expand Down

0 comments on commit e853b25

Please sign in to comment.