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

What do you say about Style/EmptyCaseCondition? #5

Closed
necojackarc opened this issue Jun 6, 2016 · 0 comments
Closed

What do you say about Style/EmptyCaseCondition? #5

necojackarc opened this issue Jun 6, 2016 · 0 comments

Comments

@necojackarc
Copy link
Contributor

necojackarc commented Jun 6, 2016

A new feature, Style/EmptyCaseCondition, was introduced on the version 0.40.0.

Let’s get straight to the point, it doesn't allow us to write like this:

# NG
def status
  case
  when active?
    :active
  when quitted?
    :quitted
  when banned?
    :banned
  when unconfirmed?
    :unconfirmed
  end
end

Now, we need to adopt the following style:

# OK
def status
  if active?
    :active
  elsif quitted?
    :quitted
  elsif banned?
    :banned
  elsif unconfirmed?
    :unconfirmed
  end
end

I've been using the former because someone told me that many elsif looked a bit ugly and I agreed.
You can find some similar opinions in the issue.

What do you think?

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