module Rubocop::Cop::Style::FavorOtherKeywordOverNegation
Some common code shared between the two cops.
Public Instance Methods
check(node)
click to toggle source
# File lib/rubocop/cop/style/favor_unless_over_negated_if.rb, line 8 def check(node) condition, _body, _rest = *node # Look at last expression of contents if there's a parenthesis # around condition. condition = condition.children.last while condition.type == :begin if condition.type == :send _object, method = *condition if method == :! && !(node.loc.respond_to?(:else) && node.loc.else) add_offence(:convention, node.loc.expression, error_message) end end end