lib/rubocop/cop/not.rb in rubocop-0.7.2 vs lib/rubocop/cop/not.rb in rubocop-0.8.0
- old
+ new
@@ -1,15 +1,21 @@
# encoding: utf-8
module Rubocop
module Cop
class Not < Cop
- ERROR_MESSAGE = 'Use ! instead of not.'
+ MSG = 'Use ! instead of not.'
- def inspect(file, source, tokens, sexp)
- each_keyword('not', tokens) do |t|
- add_offence(:convention, t.pos.lineno, ERROR_MESSAGE)
+ def on_send(node)
+ _receiver, method_name, *args = *node
+
+ # not does not take any arguments
+ if args.empty? && method_name == :! &&
+ node.loc.selector.source == 'not'
+ add_offence(:convention, node.loc.line, MSG)
end
+
+ super
end
end
end
end