lib/rubocop/cop/naming/accessor_method_name.rb in rubocop-1.5.2 vs lib/rubocop/cop/naming/accessor_method_name.rb in rubocop-1.6.0
- old
+ new
@@ -1,12 +1,18 @@
# frozen_string_literal: true
module RuboCop
module Cop
module Naming
- # This cop makes sure that accessor methods are named properly.
+ # This cop makes sure that accessor methods are named properly. Applies
+ # to both instance and class methods.
#
+ # NOTE: Offenses are only registered for methods with the expected
+ # arity. Getters (`get_attribute`) must have no arguments to be
+ # registered, and setters (`set_attribute(value)`) must have exactly
+ # one.
+ #
# @example
# # bad
# def set_attribute(value)
# end
#
@@ -18,9 +24,17 @@
# def get_attribute
# end
#
# # good
# def attribute
+ # end
+ #
+ # # accepted, incorrect arity for getter
+ # def get_value(attr)
+ # end
+ #
+ # # accepted, incorrect arity for setter
+ # def set_value
# end
class AccessorMethodName < Base
MSG_READER = 'Do not prefix reader method names with `get_`.'
MSG_WRITER = 'Do not prefix writer method names with `set_`.'