View Javadoc
1   /*
2   BooleanExpressionComplexity
3   max = 5
4   tokens = BXOR,LAND,LOR
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.metrics.booleanexpressioncomplexity;
10  
11  public class InputBooleanExpressionComplexity2 {
12      private boolean _a = false; //boolean field
13      private boolean _b = false;
14      private boolean _c = false;
15      private boolean _d = false;
16      /*public method*/
17      public void foo() {
18          if (_a && _b || _c ^ _d) {
19          }
20  
21          if (((_a && (_b & _c)) || (_c ^ _d))) {
22          }
23  
24          if (_a && _b && _c) {
25          }
26  
27          if (_a & _b) {
28          }
29  
30          if (_a) {
31          }
32      }
33  
34      public boolean equals(Object object) {
35          new NestedClass() {
36              public void method() {
37                  new Settings(Settings.FALSE || Settings.FALSE || Settings.FALSE || _a || _b);
38              }
39              public void method2() {
40              }
41          };
42          return (((_a && (_b & _c)) || (_c ^ _d) || (_a && _d)));
43      }
44  
45      public boolean bitwise()
46      {
47          return (((_a & (_b & _c)) | (_c ^ _d) | (_a & _d)));
48      }
49  
50      public void notIgnoredMethodParameters()
51      {
52          new Settings(Settings.FALSE && Settings.FALSE && Settings.FALSE
53                  && Settings.TRUE && Settings.TRUE);
54          new Settings(Settings.FALSE || Settings.FALSE || Settings.FALSE
55                  || Settings.TRUE || Settings.TRUE);
56      }
57  
58      public void ignoredMethodParameters()
59      {
60          new Settings(Settings.RESIZABLE | Settings.SCROLLBARS | Settings.LOCATION_BAR
61                  | Settings.MENU_BAR | Settings.TOOL_BAR);
62          new Settings(Settings.RESIZABLE & Settings.SCROLLBARS & Settings.LOCATION_BAR
63                  & Settings.MENU_BAR & Settings.TOOL_BAR);
64          new Settings(Settings.RESIZABLE ^ Settings.SCROLLBARS ^ Settings.LOCATION_BAR
65                  ^ Settings.MENU_BAR ^ Settings.TOOL_BAR);
66      }
67  
68      private class Settings {
69          public final static int RESIZABLE = 1;
70          public final static int SCROLLBARS = 2;
71          public final static int LOCATION_BAR = 3;
72          public final static int MENU_BAR = 4;
73          public final static int TOOL_BAR = 5;
74  
75          public final static boolean TRUE = true;
76          public final static boolean FALSE = false;
77  
78          public Settings(int flag)
79          {
80          }
81  
82          public Settings(boolean flag)
83          {
84          }
85      }
86  
87      abstract class NestedClass {
88          public abstract void method();
89          public abstract void method2();
90      }
91  }