lib/rubocop/cop/naming/accessor_method_name.rb in rubocop-1.65.1 vs lib/rubocop/cop/naming/accessor_method_name.rb in rubocop-1.66.0

- old
+ new

@@ -38,10 +38,11 @@ class AccessorMethodName < Base MSG_READER = 'Do not prefix reader method names with `get_`.' MSG_WRITER = 'Do not prefix writer method names with `set_`.' def on_def(node) + return unless proper_attribute_name?(node) return unless bad_reader_name?(node) || bad_writer_name?(node) message = message(node) add_offense(node.loc.name, message: message) @@ -54,9 +55,13 @@ if bad_reader_name?(node) MSG_READER elsif bad_writer_name?(node) MSG_WRITER end + end + + def proper_attribute_name?(node) + !node.method_name.to_s.end_with?('!', '?', '=') end def bad_reader_name?(node) node.method_name.to_s.start_with?('get_') && !node.arguments? end