Simplifiable 'if' statement
Reports if
statements that can be replaced with case
statements.
Use the Minimum number of branches field to specify the minimum number of when
branches for the resulting case
statement.
Example:
fruit = gets
if fruit == 'apple' # Simplifiable 'if' statement
puts 'This is apple!'
elsif fruit == 'peach'
puts 'This is peach!'
elsif fruit == 'orange'
puts 'This is orange!'
elsif fruit == 'banana'
puts 'This is banana!'
end
Inspection options
Option | Type | Default |
---|---|---|
Minimum number of branches | Number | 3 |
Inspection Details | |
---|---|
Available in: | Qodana for Ruby 2023.3, RubyMine 2023.3 |
Plugin: | Ruby, 233.SNAPSHOT |
Last modified: 13 July 2023