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

Increase module_function parity with public, private, and protected #1310

Closed
cupakromer opened this issue Aug 28, 2014 · 2 comments
Closed

Comments

@cupakromer
Copy link
Contributor

module_function is not treated the same as public, private, or protected with at least the following cops:

  • Style/AccessModifierIndentation
  • Style/EmptyLinesAroundAccessModifier

Here is sample code which demo's this:

# .rubocop.yml
AccessModifierIndentation:
  EnforcedStyle: outdent
# lib/rubocop_test.rb
# A sample for rubocop
module  RubocopTest
  public
  def for_all_to_see
  end

  protected
  def for_the_kids
  end

  private
  def just_for_me
  end

  module_function
  def available_or_included
  end
end
$ bin/rubocop -v; bin/rubocop -D lib
0.25.0 (using Parser 2.2.0.pre.4, running on ruby 2.1.2 x86_64-darwin13.0)
Inspecting 1 file
C

Offenses:

lib/rubocop_test.rb:4:3: C: Style/AccessModifierIndentation: Outdent access modifiers like public.
  public
  ^^^^^^
lib/rubocop_test.rb:4:3: C: Style/EmptyLinesAroundAccessModifier: Keep a blank line before and after public.
  public
  ^^^^^^
lib/rubocop_test.rb:8:3: C: Style/AccessModifierIndentation: Outdent access modifiers like protected.
  protected
  ^^^^^^^^^
lib/rubocop_test.rb:8:3: C: Style/EmptyLinesAroundAccessModifier: Keep a blank line before and after protected.
  protected
  ^^^^^^^^^
lib/rubocop_test.rb:12:3: C: Style/AccessModifierIndentation: Outdent access modifiers like private.
  private
  ^^^^^^^
lib/rubocop_test.rb:12:3: C: Style/EmptyLinesAroundAccessModifier: Keep a blank line before and after private.
  private
  ^^^^^^^

1 file inspected, 6 offenses detected

This is semi-related to #730 which added some support for module_function in the Lint/DefEndAlignment cop.

@yujinakayama
Copy link
Collaborator

👍 for this.

@bbatsov @jonas054 Thoughts?

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 1, 2014

👍 from me as well.

@bbatsov bbatsov closed this as completed in c85edca Sep 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants