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

Style/AccessorGrouping doesn't take access control into account. #8253

Closed
pat opened this issue Jul 7, 2020 · 2 comments · Fixed by #8261
Closed

Style/AccessorGrouping doesn't take access control into account. #8253

pat opened this issue Jul 7, 2020 · 2 comments · Fixed by #8261
Labels
Milestone

Comments

@pat
Copy link
Contributor

pat commented Jul 7, 2020

I have a class that has an attr_reader call at the top (default public access), and then again underneath private - essentially:

class Foo
  attr_reader :alpha, :beta

  private

  attr_reader :gamma, :delta
end

I would expect this to be fine - I only want the accessors underneath private to be available internally to the class instances - but the new Style/AccessorGrouping cop says they should all be grouped together. So, I'm guessing it's not picking up on the different access control levels? This feels like a bug to me, unless I'm missing something.

$ rubocop -V
0.87.0 (using Parser 2.7.1.4, rubocop-ast 0.1.0, running on ruby 2.6.6 x86_64-darwin19)

$ rubocop --only Style/AccessorGrouping
Inspecting 1 file
C

Offenses:

foo.rb:2:3: C: Style/AccessorGrouping: Group together all attr_reader attributes.
  attr_reader :alpha, :beta
  ^^^^^^^^^^^^^^^^^^^^^^^^^
foo.rb:6:3: C: Style/AccessorGrouping: Group together all attr_reader attributes.
  attr_reader :gamma, :delta
  ^^^^^^^^^^^^^^^^^^^^^^^^^^
@koic koic added the bug label Jul 7, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Jul 7, 2020

Sounds like a job for @fatkodima.

@fatkodima
Copy link
Contributor

Will look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants