View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="SimplifyBooleanExpression"/>
5     </module>
6   </module>
7   */
8   package com.puppycrawl.tools.checkstyle.checks.coding.simplifybooleanexpression;
9   
10  // xdoc section -- start
11  class Example1 {
12    void InvalidExample() {
13      boolean a=true;
14      boolean b=true;
15      Object c=null;
16      Object d=null;
17      Object e=null;
18      if (!false) {}; // violation, can be simplified to true
19      if (a == true) {}; // violation, can be simplified to a
20      if (a == b) {};
21      if (a == false) {}; // violation, can be simplified to !a
22      if (!(a != true)) {}; // violation, can be simplified to a
23      e = (a || b) ? c : d;
24      e = (a || false) ? c : d; // violation, can be simplified to a
25      e = (a && b) ? c : d;
26      int s = 12;
27      boolean m = s > 1 ? true : false; // violation, can be simplified to s > 1
28      boolean f = c == null ? false : c.equals(d);
29    }
30  }
31  // xdoc section -- end