codeclimate/codeclimate

View on GitHub
lib/cc/analyzer/issue_sorter.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Do not use empty case condition, instead use an if expression.
Open

        case
Severity: Minor
Found in lib/cc/analyzer/issue_sorter.rb by rubocop

Checks for case statements with an empty condition.

Example:

# bad:
case
when x == 0
  puts 'x is 0'
when y == 0
  puts 'y is 0'
else
  puts 'neither is 0'
end

# good:
if x == 0
  puts 'x is 0'
elsif y == 0
  puts 'y is 0'
else
  puts 'neither is 0'
end

# good: (the case condition node is not empty)
case n
when 0
  puts 'zero'
when 1
  puts 'one'
else
  puts 'more'
end

There are no issues that match your filters.

Category
Status