-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
According to the latest Google Style https://checkstyle.org/styleguides/google-java-style-20180523/javaguide.html#s4.6.2-horizontal-whitespace,
Between a type annotation and [] or ....
So valid cases are:
String...
String[]
, String @NotNull []
, String @NotNull ...
Invalid cases:
String ...
String []
, String @NotNull[]
, String @NotNull...
As we removing ELIPSIS token from config in #6707 to avoid false-positives (unwanted violations)
We need to make new Check to address cases above and do not make any false-positives, as general Check NoWhitespaceBefore
should not be over complicated with nuances of annotations before token.
$ cat Test.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
public class Test {
@Target(ElementType.TYPE_USE)
@interface NonNull {
}
@NonNull int @NonNull[] @NonNull[] fiel1; // false-negative
@NonNull int @NonNull [] @NonNull [] field2;
//@NonNull int @NonNull ... field3; // non-compilable
//@NonNull int @NonNull... field4; // non-compilable
public void foo2(final char[] param) {
}
public void foo1(final char [] param) {
}
public void foo3(final char @NonNull[] param) { // false-negative
}
public void foo4(final char @NonNull [] param) {
}
void test4(String... param) {
}
void test3(String ... param) { // violation on 8.32, no violation is #6707 fixes
}
void test2(String @NonNull... param) { // false-negative
}
void test1(String @NonNull ... param) { // violation on 8.32, no violation aft #6707
}
}
$ java -jar /var/tmp/checkstyle-8.32-all.jar -c /google_checks.xml Test.java
Starting audit...
[WARN] /var/tmp/Test.java:31:21: '...' is preceded with whitespace. [NoWhitespaceBefore]
[WARN] /var/tmp/Test.java:37:30: '...' is preceded with whitespace. [NoWhitespaceBefore]
Audit done.
Sub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
Status