1 /*xml 2 <module name="Checker"> 3 <module name="TreeWalker"> 4 <module name="NestedIfDepth"> 5 <property name="max" value="3"/> 6 </module> 7 </module> 8 </module> 9 */ 10 package com.puppycrawl.tools.checkstyle.checks.coding.nestedifdepth; 11 12 // xdoc section -- start 13 class Example2 { 14 void Example2() { 15 if (true) { 16 if (true) {} 17 else {} 18 } 19 20 if (true) { 21 if (true) { 22 if (true) {} 23 else{} 24 } 25 } 26 27 if (true) { 28 if (true) { 29 if (true) { 30 if (true) {} 31 else {} 32 } 33 } 34 } 35 36 if (true) { 37 if (true) { 38 if (true) { 39 if (true) { 40 if (true) { // violation, nested if-else depth is 4 (max allowed is 3) 41 if (true) {} // violation, nested if-else depth is 5 (max allowed is 3) 42 else {} 43 } 44 } 45 } 46 } 47 } 48 } 49 } 50 // xdoc section -- end