Closed
Description
Expected behavior
Naming/MethodName should flag attr_reader
, attr_writer
, and attr_accessor
for incorrect case.
Actual behavior
Only methods defined with explicit def
statements are flagged.
Steps to reproduce the problem
Given the following code:
# Foo example
class Foo
attr_accessor :fooBar
attr_reader :barBaz
attr_writer :bazQux
def quxCorge
'quxCorge'
end
def quxCorge=(_)
raise 'not a thing'
end
end
The Naming/MethodName
cop should flag all five declarations -- fooBar
, barBaz
, bazQux
, quxCorge
, and quxCorge=
Instead, only the explicit def quxCorge
and def quxCorge=
are flagged:
Inspecting 1 file
C
Offenses:
/tmp/naming.rb:10:7: C: Naming/MethodName: Use snake_case for method names.
def quxCorge
^^^^^^^^
/tmp/naming.rb:14:7: C: Naming/MethodName: Use snake_case for method names.
def quxCorge=(_)
^^^^^^^^^
1 file inspected, 2 offenses detected
RuboCop version
Include the output of rubocop -V
or bundle exec rubocop -V
if using Bundler. Here's an example:
$ [bundle exec] rubocop -V
0.74.0 (using Parser 2.6.3.0, running on ruby 2.5.1 x86_64-darwin18)
Activity
Drenmi commentedon Aug 30, 2019
Good catch, @dmolesUC!
Fix rubocop#7320 support Naming/MethodName for attr_reader / attr_wri…
stale commentedon Feb 26, 2020
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!
Drenmi commentedon Feb 29, 2020
Still relevant.
5 remaining items