Skip to content

Commit 1679b9c

Browse files
authored
Update Spotless plugin and Google Java Format (#6997)
1 parent 4d1ccf4 commit 1679b9c

28 files changed

Lines changed: 129 additions & 119 deletions

File tree

build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515
// Code formatting; defines targets "spotlessApply" and "spotlessCheck".
1616
// https://github.com/diffplug/spotless/tags ; see tags starting "gradle/"
1717
// Only works on JDK 11+ (even including the plugin crashes Gradle on JDK 8).
18-
id 'com.diffplug.spotless' version '6.25.0'
18+
id 'com.diffplug.spotless' version '7.0.2'
1919
}
2020

2121
// There is another `repositories { ... }` block below; if you change this one, change that one as well.
@@ -51,7 +51,8 @@ ext {
5151

5252
versions = [
5353
autoValue : '1.11.0',
54-
googleJavaFormat : '1.19.2',
54+
// NOTE: Google Java Format requires JDK 17 or higher as of version 1.25.0.
55+
googleJavaFormat : '1.25.2',
5556
lombok : '1.18.36',
5657
hashmapUtil : '0.0.1',
5758
reflectionUtil : '1.1.4',
@@ -256,7 +257,7 @@ allprojects { currentProj ->
256257
target '*.md', '*.tex', '.gitignore', 'Makefile'
257258
targetExclude doNotFormat
258259
// define the steps to apply to those files
259-
indentWithSpaces(2)
260+
leadingTabsToSpaces(2)
260261
trimTrailingWhitespace()
261262
// endWithNewline() // Don't want to end empty files with a newline
262263
}
@@ -298,9 +299,9 @@ allprojects { currentProj ->
298299
targetExclude doNotFormat
299300
greclipse() // which formatter Spotless should use to format .gradle files.
300301
if (project.hasProperty('eisopFormatting')) {
301-
indentWithSpaces(4)
302+
leadingTabsToSpaces(4)
302303
} else {
303-
indentWithSpaces(2)
304+
leadingTabsToSpaces(2)
304305
}
305306
trimTrailingWhitespace()
306307
// endWithNewline() // Don't want to end empty files with a newline
@@ -313,7 +314,7 @@ allprojects { currentProj ->
313314
// removes semicolons at the end of lines
314315
removeSemicolons()
315316
greclipse()
316-
indentWithSpaces(2)
317+
leadingTabsToSpaces(2)
317318
trimTrailingWhitespace()
318319
}
319320
}

checker/bin-devel/test-misc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ status=0
1616

1717
## Code style and formatting
1818
JAVA_VER=$(java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 | sed 's/-ea//')
19-
if [ "${JAVA_VER}" != "8" ] ; then
19+
if [ "${JAVA_VER}" != "8" ] && [ "${JAVA_VER}" != "11" ] ; then
2020
./gradlew spotlessCheck --console=plain --warning-mode=all
2121
fi
2222
if grep -n -r --exclude-dir=build --exclude-dir=examples --exclude-dir=jtreg --exclude-dir=tests --exclude="*.astub" --exclude="*.tex" '^\(import static \|import .*\*;$\)'; then

checker/src/main/java/org/checkerframework/checker/formatter/FormatterVisitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ public Void visitMethodInvocation(MethodInvocationTree tree, Void p) {
127127
if (!isWrappedFormatCall(fc, enclosingMethod)) {
128128
ftu.warning(invc, "format.indirect.arguments");
129129
}
130-
// TODO: If it is explict array construction, such as "new Object[] {
131-
// ... }", then we could treat it like the VARARGS case, analyzing each
132-
// argument. "new array" is probably rare, in the varargs position.
133-
// fall through
130+
// TODO: If it is explict array construction, such as "new Object[] {
131+
// ... }", then we could treat it like the VARARGS case, analyzing each
132+
// argument. "new array" is probably rare, in the varargs position.
133+
// fall through
134134
case NULLARRAY:
135135
for (ConversionCategory cat : formatCats) {
136136
if (cat == ConversionCategory.NULL) {

checker/src/main/java/org/checkerframework/checker/i18nformatter/I18nFormatterVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private void checkInvocationFormatFor(I18nFormatCall fc) {
101101
}
102102
break;
103103
case NULLARRAY:
104-
// fall-through
104+
// fall-through
105105
case ARRAY:
106106
for (I18nConversionCategory cat : formatCats) {
107107
if (cat == I18nConversionCategory.UNUSED) {

checker/src/main/java/org/checkerframework/checker/nullness/NullnessVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ protected boolean commonAssignmentCheck(
191191
|| !((IdentifierTree) receiver).getName().contentEquals("this")) {
192192
return null;
193193
}
194-
// fallthrough
194+
// fallthrough
195195
case IDENTIFIER:
196196
TreePath path = getCurrentPath();
197197
if (TreePathUtil.inConstructor(path)) {

checker/src/main/java/org/checkerframework/checker/resourceleak/ResourceLeakAnnotatedTypeFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ public boolean canCreateObligations() {
379379

380380
@Override
381381
@SuppressWarnings("TypeParameterUnusedInFormals") // Intentional abuse
382-
public <T extends GenericAnnotatedTypeFactory<?, ?, ?, ?>> @Nullable T getTypeFactoryOfSubcheckerOrNull(Class<? extends SourceChecker> subCheckerClass) {
382+
public <T extends GenericAnnotatedTypeFactory<?, ?, ?, ?>>
383+
@Nullable T getTypeFactoryOfSubcheckerOrNull(Class<? extends SourceChecker> subCheckerClass) {
383384
if (subCheckerClass == MustCallChecker.class) {
384385
if (!canCreateObligations()) {
385386
return super.getTypeFactoryOfSubcheckerOrNull(MustCallNoCreatesMustCallForChecker.class);

checker/src/main/java/org/checkerframework/checker/signedness/SignednessVisitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ public Void visitBinary(BinaryTree tree, Void p) {
142142
}
143143
break;
144144
}
145-
// Other plus binary trees should be handled in the default case.
146-
// fall through
145+
// Other plus binary trees should be handled in the default case.
146+
// fall through
147147
default:
148148
if (leftOpType.hasPrimaryAnnotation(Unsigned.class)
149149
&& rightOpType.hasPrimaryAnnotation(Signed.class)) {
@@ -305,8 +305,8 @@ public Void visitCompoundAssignment(CompoundAssignmentTree tree, Void p) {
305305
}
306306
break;
307307
}
308-
// Other plus binary trees should be handled in the default case.
309-
// fall through
308+
// Other plus binary trees should be handled in the default case.
309+
// fall through
310310
default:
311311
if (varType.hasPrimaryAnnotation(Unsigned.class)
312312
&& exprType.hasPrimaryAnnotation(Signed.class)) {

checker/tests/calledmethods-lombok/CheckerFrameworkBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ public java.lang.String toString() {
187187

188188
@org.checkerframework.dataflow.qual.SideEffectFree
189189
@java.lang.SuppressWarnings("all")
190-
public static CheckerFrameworkBuilder.@org.checkerframework.common.aliasing.qual.Unique CheckerFrameworkBuilderBuilder builder() {
190+
public static CheckerFrameworkBuilder.@org.checkerframework.common.aliasing.qual.Unique CheckerFrameworkBuilderBuilder
191+
builder() {
191192
return new CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder();
192193
}
193194
}

checker/tests/fenum/TestSwitch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void m() {
1111
int plain = 9; // FenumUnqualified
1212

1313
switch (plain) {
14-
// :: error: (type.incompatible)
14+
// :: error: (type.incompatible)
1515
case annotated:
1616
default:
1717
}
@@ -24,7 +24,7 @@ void m() {
2424
}
2525

2626
switch (annotated) {
27-
// :: error: (type.incompatible)
27+
// :: error: (type.incompatible)
2828
case 45:
2929
default:
3030
}

checker/tests/nullness/java17/SwitchExpressionInvariant.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ void method(
1212
List<@NonNull String> list =
1313
// :: error: (assignment)
1414
switch (fenum) {
15-
// :: error: (switch.expression)
15+
// :: error: (switch.expression)
1616
case 1 -> nonnullStrings;
1717
default -> nullableStrings;
1818
};
1919

2020
List<@Nullable String> list2 =
2121
switch (fenum) {
22-
// :: error: (switch.expression)
22+
// :: error: (switch.expression)
2323
case 1 -> nonnullStrings;
2424
default -> nullableStrings;
2525
};

0 commit comments

Comments
 (0)