forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#13345: Enable examples tests for SimplifyBooleanExpr…
…essionCheck
- Loading branch information
1 parent
c572129
commit 6bf58b7
Showing
5 changed files
with
54 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ces/com/puppycrawl/tools/checkstyle/checks/coding/simplifybooleanexpression/Example1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<module name="TreeWalker"> | ||
<module name="SimplifyBooleanExpression"/> | ||
</module> | ||
</module> | ||
*/ | ||
package com.puppycrawl.tools.checkstyle.checks.coding.simplifybooleanexpression; | ||
|
||
// xdoc section -- start | ||
class Example1 { | ||
void InvalidExample() { | ||
boolean a=true; | ||
boolean b=true; | ||
Object c=null; | ||
Object d=null; | ||
Object e=null; | ||
if (!false) {}; // violation, can be simplified to true | ||
if (a == true) {}; // violation, can be simplified to a | ||
if (a == b) {}; | ||
if (a == false) {}; // violation, can be simplified to !a | ||
if (!(a != true)) {}; // violation, can be simplified to a | ||
e = (a || b) ? c : d; | ||
e = (a || false) ? c : d; // violation, can be simplified to a | ||
e = (a && b) ? c : d; | ||
int s = 12; | ||
boolean m = s > 1 ? true : false; // violation, can be simplified to s > 1 | ||
boolean f = c == null ? false : c.equals(d); | ||
} | ||
} | ||
// xdoc section -- end |
34 changes: 0 additions & 34 deletions
34
...rces/com/puppycrawl/tools/checkstyle/checks/coding/simplifybooleanexpression/Example1.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters