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

EmptyLinesAroundAttributeAccessor should ignore # rubocop comments #10693

Closed
JoeCohen opened this issue Jun 5, 2022 · 0 comments · Fixed by #10694
Closed

EmptyLinesAroundAttributeAccessor should ignore # rubocop comments #10693

JoeCohen opened this issue Jun 5, 2022 · 0 comments · Fixed by #10694

Comments

@JoeCohen
Copy link
Contributor

@JoeCohen JoeCohen commented Jun 5, 2022

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

The following generates a Style/EmptyLinesAroundAttributeAccessor offense.

    # Disable cop to allow comments on each accessor in a separate line
    # rubocop:disable Style/AccessorGrouping
    attr_accessor :var      # name of global variable to assign it to if any
    attr_accessor :points   # array of [lat, long]
    attr_accessor :color    # css-format color string
    attr_accessor :weight   # width of line in pixels
    attr_accessor :opacity  # from 0.0 to 1.0
    # rubocop:enable Style/AccessorGrouping

    more code

Describe the solution you'd like

Rubocop should not generate an offense if the accessors are followed by a # rubocop: comment.

Describe alternatives you've considered

I considered excluding the file in the cop. But that would turn off the cop for the entire file.
I don't like that because it means that Rubocop will not detect other accessors that could be grouped.

Additional context

rubocop 1.30.0

JoeCohen added a commit to MushroomObserver/mushroom-observer that referenced this issue Jun 5, 2022
because disabling the cop for elected lines creates a
Style/EmptyLinesAroundAttributeAccessor offense.
See rubocop/rubocop#10693
ydah added a commit to ydah/rubocop that referenced this issue Jun 5, 2022
…uteAccessor` when there is a comment line on the next line.
ydah added a commit to ydah/rubocop that referenced this issue Jun 7, 2022
…uteAccessor` when there is a comment line on the next line.
ydah added a commit to ydah/rubocop that referenced this issue Jun 7, 2022
…uteAccessor` when there is a comment line on the next line.
ydah added a commit to ydah/rubocop that referenced this issue Jun 7, 2022
…uteAccessor` when there is a comment line on the next line.
ydah added a commit to ydah/rubocop that referenced this issue Jun 7, 2022
…uteAccessor` when there is a comment line on the next line.
koic added a commit that referenced this issue Jun 8, 2022
…round_attribute_accessor

[Fix #10693] Add ignore case for `Style/EmptyLinesAroundAttributeAccessor` when there is a comment line on the next line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant