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

Allow comments before an access modifier #2463

Closed
agrimm opened this issue Nov 30, 2015 · 1 comment
Closed

Allow comments before an access modifier #2463

agrimm opened this issue Nov 30, 2015 · 1 comment
Labels

Comments

@agrimm
Copy link
Contributor

agrimm commented Nov 30, 2015

The following code

# Demonstrate that comments aren't allowed before an access modifier
class MyClass
  def foo
    bar
  end

  # FIXME: Get rid of private methods in this class.
  private

  def bar
    puts 'bar called'
  end
end

Generates the following offense

comment_before_access_modifier.rb:8:3: C: Style/EmptyLinesAroundAccessModifier: Keep a blank line before and after private.
  private
  ^^^^^^^

If an access modifier has a comment before it, but an empty line before the comment, then it should not generate an offense, or it should be possible to configure the cop to not generate an offense.

I don't have any opinion about comments after an access modifier. I guess they should be allowed for consistency, but I don't see the point of having a comment after an access modifier.

@bbatsov bbatsov added the bug label Nov 30, 2015
@bbatsov
Copy link
Collaborator

bbatsov commented Nov 30, 2015

Good catch. This should be fixed.

@bbatsov bbatsov closed this as completed in 52450ad Dec 1, 2015
bbatsov added a commit that referenced this issue Dec 1, 2015
…odifier

[Fix #2463] Allow comments before an access modifier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants