Skip to content

Commit 055a4f3

Browse files
authored
Spotless: properly format test files (#1421)
1 parent bf4d724 commit 055a4f3

10 files changed

Lines changed: 30 additions & 33 deletions

File tree

build.gradle

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,19 +331,10 @@ allprojects { currentProj ->
331331
googleJavaFormat(versions.googleJavaFormat) // the formatter to apply to Java files
332332
}
333333
formatAnnotations().addTypeAnnotation("PolyInitialized").addTypeAnnotation("PolyVP").addTypeAnnotation("ReceiverDependentQual")
334-
}
335-
336-
java {
337-
if (currentProj != currentProj.rootProject) {
338-
// not the root project; format all .java files in the sub-project src folders
339-
target 'src/**/*.java'
340-
}
341-
targetExclude doNotFormat
342334

343-
// This really just removes the wildcard imports - they are not expanded.
344-
// That is fine for src files, which should then be manually fixed.
345335
// There are currently many tests with wildcard imports, so do not enable this for tests.
346-
removeWildcardImports()
336+
// TODO: Spotless has no easy way to only enable this for a subset of the target.
337+
// forbidWildcardImports()
347338
}
348339

349340
// Only define a groovyGradle task on the root project, for simplicity in setting the target pattern
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
ToArrayHeuristic.java:45:25: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
1+
ToArrayHeuristic.java:46:25: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
22
type of expression: @Nullable String @NonNull []
33
method return type: @NonNull String @NonNull []
4-
ToArrayHeuristic.java:45:25: compiler.warn.proc.messager: [toarray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
5-
ToArrayHeuristic.java:49:25: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
4+
ToArrayHeuristic.java:46:25: compiler.warn.proc.messager: [toarray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
5+
ToArrayHeuristic.java:50:25: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
66
type of expression: @Nullable String @NonNull []
77
method return type: @NonNull String @NonNull []
8-
ToArrayHeuristic.java:49:25: compiler.warn.proc.messager: [toarray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
8+
ToArrayHeuristic.java:50:25: compiler.warn.proc.messager: [toarray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
99
2 errors
1010
2 warnings
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
ToArrayHeuristic.java:45:25: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
1+
ToArrayHeuristic.java:46:25: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
22
type of expression: @Nullable String @NonNull []
33
method return type: @NonNull String @NonNull []
4-
ToArrayHeuristic.java:45:25: compiler.warn.proc.messager: [toarray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
4+
ToArrayHeuristic.java:46:25: compiler.warn.proc.messager: [toarray.nullable.elements.not.newarray] call of toArray on collection of non-null elements yields an array of possibly-null elements; omit the argument to toArray or make it an explicit array constructor
55
1 error
66
1 warning

checker/jtreg/nullness/ToArrayHeuristic/ToArrayHeuristic.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
*/
99

1010
import org.checkerframework.common.value.qual.ArrayLen;
11+
1112
import java.util.Collection;
1213

1314
public class ToArrayHeuristic {
1415
private final String[] EMPTY_STRING_ARRAY_LITERAL = new String[0];
1516
private final String[] EMPTY_STRING_ARRAY_BRACES = {};
1617
private final String[] NON_EMPTY_STRING_ARRAY = new String[1];
1718
String @ArrayLen(0) [] EMPTY_STRING_ARRAY_TRUSTED = {};
18-
String [] EMPTY_STRING_ARRAY_MISSING_MODIFIERS = {};
19+
String[] EMPTY_STRING_ARRAY_MISSING_MODIFIERS = {};
1920

2021
String[] literalZero(Collection<String> c) {
2122
return c.toArray(new String[0]);
@@ -54,6 +55,6 @@ String[] argWithParens(Collection<String> c) {
5455
}
5556

5657
String[] receiverSizeWithParens(Collection<String> c) {
57-
return (c).toArray(new String[((c)).size()]);
58+
return (c).toArray(new String[((c)).size()]);
5859
}
5960
}

checker/jtreg/nullness/onlyannotatedfor/AnnotatedForWithUse.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212
public class AnnotatedForWithUse {
1313
class Unannotated {
1414
Object o;
15-
Object get() { return null; }
15+
16+
Object get() {
17+
return null;
18+
}
19+
1620
void set(Object of) {}
1721
}
1822

1923
@AnnotatedFor("nullness")
2024
class AnnotatedUse {
2125
void use(Unannotated u) {
2226
// 1: OK, 2: OK, 3: Err
23-
@NonNull Object obj = u.o;
27+
@NonNull Object obj = u.o;
2428
// 1. Err, 2: Err, TODO want OK, 3: OK, TODO want Err
2529
u.o = null;
2630
// 1: OK, 2: OK, 3: Err
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
AnnotatedForWithUse.java:23:37: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment.
1+
AnnotatedForWithUse.java:27:36: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment.
22
found : @Nullable Object
33
required: @NonNull Object
4-
AnnotatedForWithUse.java:27:18: compiler.err.proc.messager: [dereference.of.nullable] dereference of possibly-null reference u.get()
5-
AnnotatedForWithUse.java:27:29: compiler.err.proc.messager: [method.invocation.invalid] call to toString() not allowed on the given receiver.
4+
AnnotatedForWithUse.java:31:18: compiler.err.proc.messager: [dereference.of.nullable] dereference of possibly-null reference u.get()
5+
AnnotatedForWithUse.java:31:29: compiler.err.proc.messager: [method.invocation.invalid] call to toString() not allowed on the given receiver.
66
found : @UnknownInitialization Object
77
required: @Initialized Object
8-
AnnotatedForWithUse.java:29:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set.
8+
AnnotatedForWithUse.java:33:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set.
99
found : @UnknownKeyFor NullType
1010
required: @KeyForBottom Object
11-
AnnotatedForWithUse.java:29:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set.
11+
AnnotatedForWithUse.java:33:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set.
1212
found : @Nullable NullType
1313
required: @NonNull Object
1414
5 errors
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
AnnotatedForWithUse.java:14:16: compiler.err.proc.messager: [initialization.field.uninitialized] the default constructor does not initialize field o
2-
AnnotatedForWithUse.java:15:31: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
2+
AnnotatedForWithUse.java:17:20: compiler.err.proc.messager: [return.type.incompatible] incompatible types in return.
33
type of expression: @Nullable NullType
44
method return type: @NonNull Object
5-
AnnotatedForWithUse.java:25:19: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment.
5+
AnnotatedForWithUse.java:29:19: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment.
66
found : @Nullable NullType
77
required: @NonNull Object
8-
AnnotatedForWithUse.java:29:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set.
8+
AnnotatedForWithUse.java:33:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set.
99
found : @Nullable NullType
1010
required: @NonNull Object
1111
4 errors
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
AnnotatedForWithUse.java:25:19: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment.
1+
AnnotatedForWithUse.java:29:19: compiler.err.proc.messager: [assignment.type.incompatible] incompatible types in assignment.
22
found : @Nullable NullType
33
required: @NonNull Object
4-
AnnotatedForWithUse.java:29:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set.
4+
AnnotatedForWithUse.java:33:19: compiler.err.proc.messager: [argument.type.incompatible] incompatible argument for parameter of of Unannotated.set.
55
found : @Nullable NullType
66
required: @NonNull Object
77
2 errors

checker/tests/nullness/ToArrayFromField.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5+
56
// Related jtreg test: checker/jtreg/nullness/ToArrayHeuristic/ToArrayHeuristic.java
67
public class ToArrayFromField {
78

framework/tests/all-systems/Issue6078.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
/**
44
* For signature polymorphic methods, javac sometimes does not include the corresponding vararg
5-
* parameter in the method type. This seems to happen for no-arg invocations and invocations with
6-
* a single argument of a primitive type.
5+
* parameter in the method type. This seems to happen for no-arg invocations and invocations with a
6+
* single argument of a primitive type.
77
*
88
* <p>We work around this issue in TreeUtils.isVarargsCall() and TreeUtils.isSignaturePolymorphic.
99
*/

0 commit comments

Comments
 (0)