I have the following warning twice with Scalastyle:
Eliminate redundant if expressions where both branches return constant booleans
The faulty code is:
if (monFeu == Rouge) true
else if (monFeu == Orange) {
if (leurFeu == Orange || leurFeu == Vert) // <- Here
true
else false
} else if (leurFeu == Orange || leurFeu == Vert) // <- here
true
else false
}
As a general rule, any if that produces the values true and false like this should be simplified to just the conditional expression. If if (leurFeu == Orange || leurFeu == Vert) true else false should be simplified to just (leurFeu == Orange || leurFeu == Vert).
As a general rule, any if that produces the values true and false like
this should be simplified to just the conditional expression. If |if
(leurFeu == Orange || leurFeu == Vert) true else false| should be
simplified to just |(leurFeu == Orange || leurFeu == Vert)|.