Method: RuboCop::Cop::Style::InverseMethods#on_block
- Defined in:
- lib/rubocop/cop/style/inverse_methods.rb
#on_block(node) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rubocop/cop/style/inverse_methods.rb', line 69 def on_block(node) inverse_block?(node) do |_method_call, method, block| return unless inverse_blocks.key?(method) return if negated?(node) && negated?(node.parent) # Inverse method offenses inside of the block of an inverse method # offense, such as `y.reject { |key, _value| !(key =~ /c\d/) }`, # can cause auto-correction to apply improper corrections. ignore_node(block) add_offense(node, message: format(MSG, method: method, inverse: inverse_blocks[method])) end end |