class RuboCop::Cop::Style::NegatedIf

end
bar
if !foo
# good
bar unless foo
# good
bar if !foo
# bad
# enforces ‘unless` for just `postfix` conditionals
@example EnforcedStyle: postfix
bar if !foo
# good
end
bar
unless foo
# good
end
bar
if !foo
# bad
# enforces `unless` for just `prefix` conditionals
@example EnforcedStyle: prefix
bar unless foo
# good
bar if !foo
# bad
end
bar
unless foo
# good
end
bar
if !foo
# bad
# enforces `unless` for `prefix` and `postfix` conditionals
@example EnforcedStyle: both (default)
- postfix
- prefix
- both
without else are considered. There are three different styles:
Checks for uses of if with a negated condition. Only ifs

def autocorrect(node)

def autocorrect(node)
  ConditionCorrector.correct_negative_condition(node)
end

def correct_style?(node)

def correct_style?(node)
  style == :prefix && node.modifier_form? ||
    style == :postfix && !node.modifier_form?
end

def message(node)

def message(node)
  format(MSG, inverse: node.inverse_keyword, current: node.keyword)
end

def on_if(node)

def on_if(node)
  return if node.elsif? || node.ternary?
  return if correct_style?(node)
  check_negative_conditional(node)
end