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

Add a cop checking for empty when expressions #3646

Closed
bbatsov opened this issue Oct 18, 2016 · 1 comment
Closed

Add a cop checking for empty when expressions #3646

bbatsov opened this issue Oct 18, 2016 · 1 comment

Comments

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 18, 2016

Code like this is valid, but slightly confusing:

case x
when y then 1
when z # do nothing
else
    3
end

Probably it'd be better to encourage people to use an explicit nil as a return value. And we definitely need a cop checking for nil returns, as those are evil (but that's another matter).

Drenmi added a commit to Drenmi/rubocop that referenced this issue Oct 19, 2016
This cop checks for `when` branches with empty bodies, e.g.:

```
case foo
when :bar then 1
when :baz #nothing
end
```
@Drenmi
Copy link
Collaborator

Drenmi commented Oct 19, 2016

And we definitely need a cop checking for nil returns, as those are evil [...]

Yay! Someone agrees with me. 😁

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