1 /*xml 2 <module name="Checker"> 3 <module name="TreeWalker"> 4 <module name="NestedForDepth"> 5 <property name="max" value="2"/> 6 </module> 7 </module> 8 </module> 9 */ 10 package com.puppycrawl.tools.checkstyle.checks.coding.nestedfordepth; 11 12 // xdoc section -- start 13 public class Example2 { 14 15 public void myTest() { 16 for(int i=0; i<10; i++) { 17 for(int j=0; j<i; j++) { 18 } 19 } 20 21 for(int i=0; i<10; i++) { 22 for(int j=0; j<i; j++) { 23 for(int k=0; k<j; k++) { 24 } 25 } 26 } 27 28 // violation 4 lines below 'Nested for depth is 3 (max allowed is 2).' 29 for(int i=0; i<10; i++) { 30 for(int j=0; j<i; j++) { 31 for(int k=0; k<j; k++) { 32 for(int l=0; l<k; l++) { 33 } 34 } 35 } 36 } 37 } 38 } 39 // xdoc section -- end