Skip to content

Commit 0146f4f

Browse files
dvandersluisbbatsov
authored andcommitted
[Fix #7801] Update documentation for Naming/AccessorMethodName.
1 parent ebd90fb commit 0146f4f

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

lib/rubocop/cop/naming/accessor_method_name.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
module RuboCop
44
module Cop
55
module Naming
6-
# This cop makes sure that accessor methods are named properly.
6+
# This cop makes sure that accessor methods are named properly. Applies
7+
# to both instance and class methods.
8+
#
9+
# NOTE: Offenses are only registered for methods with the expected
10+
# arity. Getters (`get_attribute`) must have no arguments to be
11+
# registered, and setters (`set_attribute(value)`) must have exactly
12+
# one.
713
#
814
# @example
915
# # bad
@@ -21,6 +27,14 @@ module Naming
2127
# # good
2228
# def attribute
2329
# end
30+
#
31+
# # accepted, incorrect arity for getter
32+
# def get_value(attr)
33+
# end
34+
#
35+
# # accepted, incorrect arity for setter
36+
# def set_value
37+
# end
2438
class AccessorMethodName < Base
2539
MSG_READER = 'Do not prefix reader method names with `get_`.'
2640
MSG_WRITER = 'Do not prefix writer method names with `set_`.'

0 commit comments

Comments
 (0)