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

Check for redundant visibility modifiers #2462

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

Check for redundant visibility modifiers #2462

agrimm opened this issue Nov 29, 2015 · 1 comment

Comments

@agrimm
Copy link
Contributor

agrimm commented Nov 29, 2015

The following code doesn't generate any RuboCop offenses, even though it has a redundant visibility modifier, in that there's a second private call.

# Example of a class with repeated private visibility modifiers
class MyClass
  def foo
    # This is public
    bar
    baz
  end

  private

  def bar
    # This is private
    puts 'bar called'
  end

  # Redundant visibility modifier

  private

  def baz
    # This is also private
    puts 'baz called'
  end
end

MyClass.new.foo

There should be a cop that generates an offense for the second private.

@bbatsov
Copy link
Collaborator

bbatsov commented Nov 30, 2015

Yeah, we should definitely generate some offence in such situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants