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

Comments

Projects
None yet
2 participants
@bbatsov
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

[Fix rubocop-hq#3646] Add new `Lint/EmptyWhen` cop
This cop checks for `when` conditions with empty bodies, e.g.:

```
case foo
when :bar then 1
when :baz #nothing
end
```

Drenmi added a commit to Drenmi/rubocop that referenced this issue Oct 19, 2016

[Fix rubocop-hq#3646] Add new `Lint/EmptyWhen` cop
This cop checks for `when` conditions with empty bodies, e.g.:

```
case foo
when :bar then 1
when :baz #nothing
end
```

Drenmi added a commit to Drenmi/rubocop that referenced this issue Oct 19, 2016

[Fix rubocop-hq#3646] Add new `Lint/EmptyWhen` cop
This cop checks for `when` conditions with empty bodies, e.g.:

```
case foo
when :bar then 1
when :baz #nothing
end
```

Drenmi added a commit to Drenmi/rubocop that referenced this issue Oct 19, 2016

[Fix rubocop-hq#3646] Add new `Lint/EmptyWhen` cop
This cop checks for `when` conditions with empty bodies, e.g.:

```
case foo
when :bar then 1
when :baz #nothing
end
```

Drenmi added a commit to Drenmi/rubocop that referenced this issue Oct 19, 2016

[Fix rubocop-hq#3646] Add new `Lint/EmptyWhen` cop
This cop checks for `when` conditions with empty bodies, e.g.:

```
case foo
when :bar then 1
when :baz #nothing
end
```

Drenmi added a commit to Drenmi/rubocop that referenced this issue Oct 19, 2016

[Fix rubocop-hq#3646] Add new `Lint/EmptyWhen` cop
This cop checks for `when` branches with empty bodies, e.g.:

```
case foo
when :bar then 1
when :baz #nothing
end
```

Drenmi added a commit to Drenmi/rubocop that referenced this issue Oct 19, 2016

[Fix rubocop-hq#3646] Add new `Lint/EmptyWhen` cop
This cop checks for `when` branches with empty bodies, e.g.:

```
case foo
when :bar then 1
when :baz #nothing
end
```

Drenmi added a commit to Drenmi/rubocop that referenced this issue Oct 19, 2016

[Fix rubocop-hq#3646] Add new `Lint/EmptyWhen` cop
This cop checks for `when` branches with empty bodies, e.g.:

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

This comment has been minimized.

Show comment
Hide comment
@Drenmi

Drenmi Oct 19, 2016

Collaborator

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

Yay! Someone agrees with me. 😁

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. 😁

@bbatsov bbatsov closed this in 72be0f7 Oct 19, 2016

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