Module: Rubocop::Cop::Style::FavorOtherKeywordOverNegation
- Included in:
- FavorUnlessOverNegatedIf, FavorUntilOverNegatedWhile
- Defined in:
- lib/rubocop/cop/style/favor_unless_over_negated_if.rb
Overview
Some common code shared between the two cops.
Instance Method Summary collapse
Instance Method Details
#check(node) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 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) convention(node, :expression, ) end end end |