1 /* 2 com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck 3 id = ignore 4 format = (default)^[a-z][a-zA-Z0-9]*$ 5 applyToPublic = (default)true 6 applyToProtected = (default)true 7 applyToPackage = (default)true 8 applyToPrivate = (default)true 9 10 com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck 11 id = 12 format = (default)^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$ 13 applyToPublic = (default)true 14 applyToProtected = (default)true 15 applyToPackage = (default)true 16 applyToPrivate = (default)true 17 18 com.puppycrawl.tools.checkstyle.checks.UncommentedMainCheck 19 id = ignore 20 excludedClasses = (default)^$ 21 22 com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck 23 max = (default)7 24 ignoreOverriddenMethods = (default)false 25 tokens = (default)METHOD_DEF, CTOR_DEF 26 27 com.puppycrawl.tools.checkstyle.checks.coding.IllegalCatchCheck 28 illegalClassNames = (default)Error, Exception, RuntimeException, Throwable, java.lang.Error, \ 29 java.lang.Exception, java.lang.RuntimeException, java.lang.Throwable 30 31 com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck 32 scope = PRIVATE 33 excludeScope = (default)null 34 skipAnnotations = (default)Generated 35 tokens = (default)INTERFACE_DEF, CLASS_DEF, ENUM_DEF, ANNOTATION_DEF, RECORD_DEF 36 37 */ 38 package com.puppycrawl.tools.checkstyle.filters.suppresswarningsfilter; 39 40 /** 41 * Test input for using comments to suppress violations. 42 * 43 * @author Trevor Robinson 44 */ 45 @SuppressWarnings("foo") // coverage: no following AST 46 class InputSuppressWarningsFilterWithoutFilter { 47 // AST coverage 48 @SuppressWarnings("foo") interface I { } // violation 'Missing a Javadoc comment' 49 @SuppressWarnings("foo") enum E { } // violation 'Missing a Javadoc comment' 50 @SuppressWarnings("foo") InputSuppressWarningsFilterWithoutFilter() { } 51 @SuppressWarnings("foo") @interface A { } // violation 'Missing a Javadoc comment' 52 53 // include a non-checkstyle suppression; suppression on same line 54 @SuppressWarnings("unused") int I; // violation ''I' must match .* \Q'^[a-z][a-zA-Z0-9]*$'\E' 55 @SuppressWarnings({"membername"}) 56 private int J; // violation 'Name 'J' must match pattern \Q'^[a-z][a-zA-Z0-9]*$'\E' 57 private int K; // violation 'Name 'K' must match pattern \Q'^[a-z][a-zA-Z0-9]*$'\E' 58 59 // DO NOT REFORMAT: L and X should be on the same line 60 @SuppressWarnings(value="membername") 61 private int L; private int X; // 2 violations 62 // L should NOT fail, X should 63 64 // test "checkstyle:" prefix 65 @SuppressWarnings("checkstyle:ConstantName") 66 private static final int m = 0; // violation 67 private static final int n = 0; // violation 68 69 // test explicit warning alias 70 @SuppressWarnings("paramnum") 71 // should NOT fail ParameterNumberCheck 72 void foo(@SuppressWarnings("unused") int a, // violation 'More than 7 param.* (.* 8)' 73 int b, int c, int d, int e, int f, int g, int h) { 74 @SuppressWarnings("unused") int z; 75 try { } 76 catch (Exception ex) { // violation 'Catching 'Exception' is not allowed' 77 // should fail IllegalCatchCheck 78 } 79 } 80 81 // test fully qualified annotation name 82 @java.lang.SuppressWarnings("illegalCatch") 83 public void needsToCatchException() { 84 try { } 85 catch (Exception ex) { // violation 'Catching 'Exception' is not allowed' 86 // should NOT fail IllegalCatchCheck 87 } 88 } 89 90 enum AnEnum { // violation 'Missing a Javadoc comment' 91 @SuppressWarnings("rawtypes") 92 ELEMENT; 93 } 94 private static final String UNUSED="UnusedDeclaration"; 95 96 @SuppressWarnings(UNUSED) 97 public void annotationUsingStringConstantValue(){ } 98 99 @SuppressWarnings("checkstyle:uncommentedmain") // violation 'Uncommented main method found' 100 public static void main(String[] args) { } 101 102 static class TestClass1 { // violation 'Missing a Javadoc comment' 103 @SuppressWarnings("uncommentedmain") // violation 'Uncommented main method found' 104 public static void main(String[] args) { } 105 } 106 107 static class TestClass2 { // violation 'Missing a Javadoc comment' 108 @SuppressWarnings("UncommentedMain") // violation 'Uncommented main method found' 109 public static void main(String[] args) { } 110 } 111 112 static class TestClass3 { // violation 'Missing a Javadoc comment' 113 @SuppressWarnings("checkstyle:UncommentedMain") // violation 'Uncommented main method found' 114 public static void main(String[] args) { } 115 } 116 117 @SuppressWarnings("checkstyle:javadoctype") // violation 'Missing a Javadoc comment' 118 public static abstract class Task { } 119 }