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

Change misleading message of Style/EmptyLinesAroundAccessModifier: #3503

Closed
ShockwaveNN opened this issue Sep 16, 2016 · 2 comments
Closed
Labels

Comments

@ShockwaveNN
Copy link
Contributor

ShockwaveNN commented Sep 16, 2016

If we have file test.rb with code:

module A
  private
  def a
  end
end

rubocop show warning: test.rb:2:3: C: Keep a blank line before and after private.
Ok, manually add blank line before and after private:

module A

  private

  def a
  end
end

No good: test.rb:2:1: C: Extra empty line detected at module body beginning.

Accroding to #3480 (comment) - best way is to make two different messages for both cases.

RuboCop version

$ rubocop -V
0.42.0 (using Parser 2.3.1.2, running on ruby 2.1.10 x86_64-linux)
@bquorning
Copy link
Contributor

I was gonna point out that Style/EmptyLinesAroundModuleBody can be configured with EnforcedStyle: empty_lines, in which case the existing message “Keep a blank line before and after private” fits perfectly.

But that’s actually a bad argument, since EmptyLinesAroundModuleBody would complain about the missing blank line above private, while EmptyLinesAroundAccessModifier would complain about the missing blank line below:

test.rb:2:1: C: Style/EmptyLinesAroundModuleBody: Empty line missing at module body beginning.
  private
^
test.rb:2:3: C: Style/EmptyLinesAroundAccessModifier: Keep a blank line before and after private.
  private
  ^^^^^^^
test.rb:5:1: C: Style/EmptyLinesAroundModuleBody: Empty line missing at module body end.
end
^

@bquorning
Copy link
Contributor

Suggested fix in #3527.

bquorning added a commit to bquorning/rubocop that referenced this issue Sep 30, 2016
The `Style/EmptyLinesAroundAccessModifier` would always say it needed a blank
line both above and below an access modifier, even if it was at the beginning of
a class, module, or block, where there actually shouldn't be a blank line above.
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
The `Style/EmptyLinesAroundAccessModifier` would always say it needed a blank
line both above and below an access modifier, even if it was at the beginning of
a class, module, or block, where there actually shouldn't be a blank line above.
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

3 participants