forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InputArrayTrailingCommaAlwaysDemandTrailingComma.java
59 lines (53 loc) · 1.62 KB
/
InputArrayTrailingCommaAlwaysDemandTrailingComma.java
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
/*
ArrayTrailingComma
alwaysDemandTrailingComma = true
*/
package com.puppycrawl.tools.checkstyle.checks.coding.arraytrailingcomma;
public class InputArrayTrailingCommaAlwaysDemandTrailingComma {
public int[] test() {
if (true) {
return new int[]{0,};
}
return new int[]{0}; // violation 'Array should contain trailing comma.'
}
public int[] test2() {
if (true) {
return new int[]{0, 1,};
}
return new int[]{0, 1}; // violation 'Array should contain trailing comma.'
}
public void test3() {
int[] a = new int[]
{0}; // violation 'Array should contain trailing comma.'
int[] b = new int[]
{0, 1}; // violation 'Array should contain trailing comma.'
int[] c = new int[]
{0, 1,
2, 3 // violation 'Array should contain trailing comma.'
};
int[] d = new int[]
{
1,
2,
3 // violation 'Array should contain trailing comma.'
};
int[] e = new int[]
{
1,
5,
6,
};
int[] f = {1,
2 // violation 'Array should contain trailing comma.'
};
int[] g = {1,
2,
};
int[][] empty2d = {{}}; // violation 'Array should contain trailing comma.'
int[][] multiDimensionalArray = {
{1, 2}, // violation 'Array should contain trailing comma.'
{1,},
{3, 2, 1,} // violation 'Array should contain trailing comma.'
};
}
}