Parent

Methods

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::NegatedIf

Checks for uses of if with a negated condition. Only ifs without else are considered.

Constants

MSG

Public Instance Methods

message(node) click to toggle source
# File lib/rubocop/cop/style/negated_if.rb, line 19
def message(node)
  if node.loc.keyword.is?('if')
    format(MSG, 'unless', 'if')
  else
    format(MSG, 'if', 'unless')
  end
end
on_if(node) click to toggle source
# File lib/rubocop/cop/style/negated_if.rb, line 12
def on_if(node)
  return unless node.loc.respond_to?(:keyword)
  return if node.loc.keyword.is?('elsif')

  check(node)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.