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/BisectedAttrAccessor doesn't respect public/private #8259

Closed
ujh opened this issue Jul 7, 2020 · 5 comments · Fixed by #8263
Closed

Style/BisectedAttrAccessor doesn't respect public/private #8259

ujh opened this issue Jul 7, 2020 · 5 comments · Fixed by #8263
Labels

Comments

@ujh
Copy link

ujh commented Jul 7, 2020

Is your feature request related to a problem? Please describe.

Often times I only want to make the attr_reader public, but still define the attr_writer privately for internal use. However, with this cop enabled (especially with autocorrect turned on) this totally changes the access rules and therefore the API of the class.

Describe the solution you'd like

I have no idea how easy this would be to implement, but it would be great if the cop could only "fire" (is that the correct term?) if the reader and writer have the same access level, i.e. both public, private, or protected.

@koic koic added the duplicate label Jul 7, 2020
@koic
Copy link
Member

koic commented Jul 7, 2020

Dup with #8253.

@koic koic closed this as completed Jul 7, 2020
@koic koic added bug and removed duplicate labels Jul 7, 2020
@koic
Copy link
Member

koic commented Jul 7, 2020

Ah, the above comment is my mistaken. this is a different cop that is similar to Style/AccessorGrouping cop.

@hwo411
Copy link

hwo411 commented Jul 7, 2020

Also just run into it when upgraded rubocop version.

Basic example:

class A
  attr_reader :q

  private

  attr_writer :q
end
qwe.rb:2:15: C: Style/BisectedAttrAccessor: Combine both accessors into attr_accessor :q.
  attr_reader :q
              ^^
qwe.rb:6:15: C: Style/BisectedAttrAccessor: Combine both accessors into attr_accessor :q.
  attr_writer :q
              ^^

@hwo411
Copy link

hwo411 commented Jul 7, 2020

@koic could you reopen it?

@koic koic reopened this Jul 7, 2020
@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