blob: 4efd42c13e8cca3b7113dd985299fe580c77595b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
////////////////////////////////////////////////////////////////////////////////
// Test case file for checkstyle.
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.filters;
/**
* Test input for using comments to suppress errors.
*
* @author Trevor Robinson
**/
@SuppressWarnings("foo") // coverage: no following AST
class InputSuppressWarningsFilter
{
// AST coverage
@SuppressWarnings("foo") interface I { }
@SuppressWarnings("foo") enum E { }
@SuppressWarnings("foo") InputSuppressWarningsFilter() { }
@SuppressWarnings("foo") @interface A { }
// include a non-checkstyle suppression; suppression on same line
@SuppressWarnings("unused") private int I; // should fail MemberNameCheck
@SuppressWarnings({"membername"})
private int J; // should NOT fail MemberNameCheck
private int K; // should fail MemberNameCheck
// DO NOT REFORMAT: L and X should be on the same line
@SuppressWarnings(value="membername")
private int L; private int X; // L should NOT fail, X should
// test "checkstyle:" prefix
@SuppressWarnings("checkstyle:ConstantName")
private static final int m = 0; // should NOT fail ConstantNameCheck
private static final int n = 0; // should fail ConstantNameCheck
// test explicit warning alias
@SuppressWarnings("paramnum")
// should NOT fail ParameterNumberCheck
public void needsLotsOfParameters(@SuppressWarnings("unused") int a,
int b, int c, int d, int e, int f, int g, int h)
{
@SuppressWarnings("unused") int z;
try {
}
catch (Exception ex) {
// should fail IllegalCatchCheck
}
}
// test fully qualified annotation name
@java.lang.SuppressWarnings("illegalCatch")
public void needsToCatchException()
{
try {
}
catch (Exception ex) {
// should NOT fail IllegalCatchCheck
}
}
enum AnEnum {
@SuppressWarnings("rawtypes")
ELEMENT;
}
private static final String UNUSED="UnusedDeclaration";
@SuppressWarnings(UNUSED)
public void annotationUsingStringConstantValue(){
}
}
|