Methods

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::NegativeConditional

Some common code shared between FavorUnlessOverNegatedIf and FavorUntilOverNegatedWhile.

Public Instance Methods

check(node) click to toggle source
# File lib/rubocop/cop/mixin/negative_conditional.rb, line 7
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
  return unless condition.type == :send

  _object, method = *condition
  return unless method == :! && !(node.loc.respond_to?(:else) &&
                                  node.loc.else)

  add_offense(node, :expression)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.