1
2
3
4
5
6
7
8
9 package com.puppycrawl.tools.checkstyle.checks.metrics.booleanexpressioncomplexity;
10
11 public class InputBooleanExpressionComplexity {
12 private boolean _a = false;
13 private boolean _b = false;
14 private boolean _c = false;
15 private boolean _d = false;
16
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 ||
38 Settings.FALSE || _a || _b);
39 }
40 public void method2() {
41 }
42 };
43 return (((_a && (_b & _c)) || (_c ^ _d) || (_a && _d)));
44 }
45
46 public boolean bitwise()
47 {
48 return (((_a & (_b & _c)) | (_c ^ _d) | (_a & _d)));
49 }
50
51 public void notIgnoredMethodParameters()
52 {
53 new Settings(Settings.FALSE && Settings.FALSE && Settings.FALSE
54 && Settings.TRUE && Settings.TRUE);
55 new Settings(Settings.FALSE || Settings.FALSE || Settings.FALSE
56 || Settings.TRUE || Settings.TRUE);
57 }
58
59 public void ignoredMethodParameters()
60 {
61 new Settings(Settings.RESIZABLE | Settings.SCROLLBARS | Settings.LOCATION_BAR
62 | Settings.MENU_BAR | Settings.TOOL_BAR);
63 new Settings(Settings.RESIZABLE & Settings.SCROLLBARS & Settings.LOCATION_BAR
64 & Settings.MENU_BAR & Settings.TOOL_BAR);
65 new Settings(Settings.RESIZABLE ^ Settings.SCROLLBARS ^ Settings.LOCATION_BAR
66 ^ Settings.MENU_BAR ^ Settings.TOOL_BAR);
67 }
68
69 private class Settings {
70 public final static int RESIZABLE = 1;
71 public final static int SCROLLBARS = 2;
72 public final static int LOCATION_BAR = 3;
73 public final static int MENU_BAR = 4;
74 public final static int TOOL_BAR = 5;
75
76 public final static boolean TRUE = true;
77 public final static boolean FALSE = false;
78
79 public Settings(int flag)
80 {
81 }
82
83 public Settings(boolean flag)
84 {
85 }
86 }
87
88 abstract class NestedClass {
89 public abstract void method();
90 public abstract void method2();
91 }
92 }