Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming/MethodName doesn't flag attr_reader / attr_writer / attr_accessor #7320

Closed
dmolesUC opened this issue Aug 29, 2019 · 3 comments · Fixed by #7372
Closed

Naming/MethodName doesn't flag attr_reader / attr_writer / attr_accessor #7320

dmolesUC opened this issue Aug 29, 2019 · 3 comments · Fixed by #7372
Assignees

Comments

@dmolesUC
Copy link
Contributor

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)
@Drenmi
Copy link
Collaborator

Drenmi commented Aug 30, 2019

Good catch, @dmolesUC!

@stale
Copy link

stale bot commented 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!

@stale stale bot added the stale Issues that haven't been active in a while label Feb 26, 2020
@Drenmi
Copy link
Collaborator

Drenmi commented Feb 29, 2020

Still relevant.

@stale stale bot removed the stale Issues that haven't been active in a while label Feb 29, 2020
@Drenmi Drenmi self-assigned this Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment