Modify the rule to meet the missing case
This commit is contained in:
@ -1289,7 +1289,8 @@ public void foo() throws Exception {
|
||||
<description>
|
||||
<![CDATA[
|
||||
Look for ternary operators with the form `condition ? literalBoolean : foo`
|
||||
or `condition ? foo : literalBoolean`.
|
||||
or `condition ? foo : literalBoolean`
|
||||
or `condition ? literalBoolean1 : literalBoolean2`.
|
||||
|
||||
These expressions can be simplified respectively to
|
||||
`condition || foo` when the literalBoolean is true
|
||||
@ -1297,6 +1298,11 @@ These expressions can be simplified respectively to
|
||||
or
|
||||
`!condition || foo` when the literalBoolean is true
|
||||
`condition && foo` when the literalBoolean is false
|
||||
or
|
||||
`true` when the literalBoolean are both true
|
||||
`false` when the literalBoolean are both false
|
||||
`condition` when the literalBoolean1 is true and the literalBoolean2 is false
|
||||
`!condition` when the literalBoolean1 is false and the literalBoolean2 is true
|
||||
]]>
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
@ -1308,6 +1314,8 @@ or
|
||||
//ConditionalExpression[not(PrimaryExpression/*/Literal) and (Expression/PrimaryExpression/*/Literal/BooleanLiteral)]
|
||||
|
|
||||
//ConditionalExpression[not(Expression/PrimaryExpression/*/Literal) and (PrimaryExpression/*/Literal/BooleanLiteral)]
|
||||
|
|
||||
//ConditionalExpression[(PrimaryExpression/*/Literal/BooleanLiteral) and (Expression/PrimaryExpression/*/Literal/BooleanLiteral)]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
@ -1330,6 +1338,10 @@ public class Foo {
|
||||
public void test4() {
|
||||
final boolean otherValue = condition ? something() : false; // can be as simple as condition && something();
|
||||
}
|
||||
|
||||
public boolean test5() {
|
||||
return condition ? true : false; // can be as simple as return condition;
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
|
Reference in New Issue
Block a user