Class: RuboCop::Cop::Rails::AssertNot

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/rails/assert_not.rb

Overview

Use ‘assert_not` instead of `assert !`.

Examples:

# bad
assert !x

# good
assert_not x

Constant Summary collapse

MSG =
'Prefer `assert_not` over `assert !`.'
RESTRICT_ON_SEND =
%i[assert].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/rubocop/cop/rails/assert_not.rb', line 23

def on_send(node)
  return unless offensive?(node)

  add_offense(node) do |corrector|
    expression = node.source_range

    corrector.replace(expression, corrected_source(expression.source))
  end
end