Module: RuboCop::Cop::PatternMatchingHelp
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Included In:
| |
| Defined in: | lib/rubocop/cop/mixin/pattern_matching_help.rb |
Overview
Common functionality for checking whether a node is used in a pattern of pattern matching, where only some expressions are allowed.
Constant Summary
-
PATTERN_TYPES =
# File 'lib/rubocop/cop/mixin/pattern_matching_help.rb', line 8%i[ array_pattern array_pattern_with_tail begin const_pattern find_pattern hash_pattern match_alt match_as pair ].freeze
Instance Method Summary
- #in_pattern?(node) ⇒ Boolean private
Instance Method Details
#in_pattern?(node) ⇒ Boolean (private)
# File 'lib/rubocop/cop/mixin/pattern_matching_help.rb', line 15
def in_pattern?(node) child = node node.each_ancestor do |ancestor| case ancestor.type when :in_pattern return ancestor.pattern.equal?(child) when :match_pattern, :match_pattern_p return ancestor.children[1].equal?(child) when *PATTERN_TYPES child = ancestor else return false end end false end