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

EmptyLinesAroundArguments vs. anonymous modules #5219

Closed
palkan opened this issue Dec 12, 2017 · 1 comment
Closed

EmptyLinesAroundArguments vs. anonymous modules #5219

palkan opened this issue Dec 12, 2017 · 1 comment

Comments

@palkan
Copy link
Contributor

palkan commented Dec 12, 2017

Example file

# frozen_string_literal: true

module Test # :nodoc:
  def something(a, b)
    a && b
  end

  def anything(a, b)
    a || b
  end
end

Test.prepend(Module.new do
  def something(*)
    true
  end

  def anything(*)
    false
  end
end)

Expected behavior

Not sure about what should be expected. I mean, I'm not sure whether using anonymous modules this way is considered a bad practice. If not then we should allow blank lines between methods definitions.

Another problem here is the output:

spaces_test.rb:5:1: C: Layout/EmptyLinesAroundArguments: Empty line detected around arguments.
    a && b
^

It's definitely broken.

RuboCop version

Latest master ( a28c9b22) on ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16].

/cc @garettarrowood

@garettarrowood
Copy link
Contributor

garettarrowood commented Dec 12, 2017

This issue makes sense. Right now EmptyLinesAroundArguments does not consider the type of argument it receives. Adding a return if node.arguments.any?(&:block_type?) guard clause makes your example pass. But give me a little longer to make sure the cop still registers when an empty line comes somewhere before a block arg.

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

2 participants