1 /*xml 2 <module name="Checker"> 3 <module name="TreeWalker"> 4 <module name="BooleanExpressionComplexity"/> 5 </module> 6 </module> 7 */ 8 package com.puppycrawl.tools.checkstyle.checks.metrics.booleanexpressioncomplexity; 9 10 // xdoc section -- start 11 public class Example1 12 { 13 public static void main(String ... args) 14 { 15 boolean a = true; 16 boolean b = false; 17 18 boolean c = (a & b) | (b ^ a); // OK, 1(&) + 1(|) + 1(^) = 3 (max allowed 3) 19 20 boolean d = (a & b) | (b ^ a) | (a ^ b); 21 // violation above, 'Boolean expression complexity is 5 (max allowed is 3)' 22 // 1(&) + 1(|) + 1(^) + 1(|) + 1(^) = 5 23 24 boolean e = a ^ (a || b) ^ (b || a) & (a | b); 25 // violation above, 'Boolean expression complexity is 6 (max allowed is 3)' 26 // 1(^) + 1(||) + 1(^) + 1(||) + 1(&) + 1(|) = 6 27 } 28 } 29 // xdoc section -- end