lib/rubocop/cop/naming/accessor_method_name.rb in rubocop-0.50.0 vs lib/rubocop/cop/naming/accessor_method_name.rb in rubocop-0.51.0

- old
+ new

@@ -17,16 +17,17 @@ # # # good # def attribute ... class AccessorMethodName < Cop def on_def(node) - if bad_reader_name?(node) - add_offense(node, :name, - 'Do not prefix reader method names with `get_`.') - elsif bad_writer_name?(node) - add_offense(node, :name, - 'Do not prefix writer method names with `set_`.') - end + msg = + if bad_reader_name?(node) + 'Do not prefix reader method names with `get_`.' + elsif bad_writer_name?(node) + 'Do not prefix writer method names with `set_`.' + end + + add_offense(node, location: :name, message: msg) if msg end alias on_defs on_def private