1 /*xml 2 <module name="Checker"> 3 <module name="TreeWalker"> 4 <module name="SuppressWarnings"> 5 <property name="format" 6 value="^unchecked$|^unused$"/> 7 <property name="tokens" 8 value=" 9 CLASS_DEF,INTERFACE_DEF,ENUM_DEF, 10 ANNOTATION_DEF,ANNOTATION_FIELD_DEF, 11 ENUM_CONSTANT_DEF,METHOD_DEF,CTOR_DEF 12 "/> 13 </module> 14 </module> 15 </module> 16 */ 17 18 package com.puppycrawl.tools.checkstyle.checks.annotation.suppresswarnings; 19 20 // xdoc section -- start 21 // ok below, since we are only checking for '^unchecked$|^unused$' 22 @SuppressWarnings("") 23 class Example2 { 24 // ok below as VARIABLE_DEF is not configured in tokens to check 25 @SuppressWarnings("") 26 final int num1 = 1; 27 @SuppressWarnings("all") 28 final int num2 = 2; 29 @SuppressWarnings("unused") 30 final int num3 = 3; 31 32 // ok below as PARAMETER_DEF is not configured in tokens to check 33 void foo1(@SuppressWarnings("unused") int param) {} 34 35 // ok below, since we are only checking for '^unchecked$|^unused$' 36 @SuppressWarnings("all") 37 void foo2(int param) {} 38 39 // violation below, 'The warning 'unused' cannot be suppressed at this location' 40 @SuppressWarnings("unused") 41 void foo3(int param) {} 42 43 // violation below, 'The warning 'unused' cannot be suppressed at this location' 44 @SuppressWarnings(true?"all":"unused") 45 void foo4(int param) {} 46 } 47 48 // violation below, 'The warning 'unchecked' cannot be suppressed at this location' 49 @SuppressWarnings("unchecked") 50 class Test2 {} 51 // xdoc section -- end