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

Lint/Void false positive result #9792

Closed
kvokka opened this issue May 12, 2021 · 2 comments · Fixed by #9796
Closed

Lint/Void false positive result #9792

kvokka opened this issue May 12, 2021 · 2 comments · Fixed by #9796

Comments

@kvokka
Copy link

kvokka commented May 12, 2021

Expected behavior

class Foo
  def foo
    1..100.times do |_n|
      break unless rand > 0.5
    end
    raise
  end
end

be ok

Actual behavior

$ be rubocop
foo.rb:5:5: W: Lint/Void: Literal 1..100.times do |_n|
      break unless rand > 0.5
    end used in void context.
    1..100.times do |_n| ...
    ^^^^^^^^^^^^^^^^^^^^

If replace to (1..100).times then everything works as it should

RuboCop version

1.14.0 (using Parser 3.0.1.1, rubocop-ast 1.5.0, running on ruby 2.7.2 x86_64-darwin19)
@koic
Copy link
Member

koic commented May 12, 2021

I couldn't reproduce it.

foo.rb:9:5: W: Lint/Void: Literal 1..50.times do

Can you provide me the whole foo.rb? The code snippet may be missing.

@kvokka
Copy link
Author

kvokka commented May 12, 2021

Can you provide me the whole foo.rb? The code snippet may be missing.

@koic
Sorry, my bad, cut out too much. Fixed the first message with the correct snippet

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

Successfully merging a pull request may close this issue.

2 participants