pixta-dev / pixta-rubocop

1 stars 1 forks source link

What do you say about `Style/EmptyCaseCondition`? #5

Closed necojackarc closed 8 years ago

necojackarc commented 8 years ago

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?