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 should detect Kernel.tap as void-context-method #5512

Closed
untitaker opened this issue Jan 27, 2018 · 0 comments
Closed

Lint/Void should detect Kernel.tap as void-context-method #5512

untitaker opened this issue Jan 27, 2018 · 0 comments

Comments

@untitaker
Copy link
Contributor

untitaker commented Jan 27, 2018

Kernel.tap ignores the return value of the passed block. Rubocop should know about this.

The following code should emit a linting error, since it was clearly the programmer's intent to write a program that outputs 7:

a = 4.tap do |x|
  x = x + 3
  x
end

puts a

However, the actual behavior is that Rubocop (from master) is completely fine with that code.

I think the fix is trivial, since rubocop does analysis like this for each already. Will open a PR soon

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

1 participant