Skip to content

Update to Spotless 7.0.1 and run spotlessApply #1054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
// Code formatting; defines targets "spotlessApply" and "spotlessCheck".
// https://github.com/diffplug/spotless/tags ; see tags starting "gradle/"
// Only works on JDK 11+.
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.25.0'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:7.0.1'
}
}
}
Expand Down Expand Up @@ -277,7 +277,7 @@ allprojects {
target '*.md', '*.tex', '.gitignore', 'Makefile'
targetExclude doNotFormat
// define the steps to apply to those files
indentWithSpaces(2)
leadingTabsToSpaces(2)
trimTrailingWhitespace()
// endWithNewline() // Don't want to end empty files with a newline
}
Expand Down Expand Up @@ -314,7 +314,7 @@ allprojects {
target '**/*.gradle'
targetExclude doNotFormat
greclipse() // which formatter Spotless should use to format .gradle files.
indentWithSpaces(4)
leadingTabsToSpaces(4)
trimTrailingWhitespace()
// endWithNewline() // Don't want to end empty files with a newline
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ public Void visitMethodInvocation(MethodInvocationTree tree, Void p) {
if (!isWrappedFormatCall(fc, enclosingMethod)) {
ftu.warning(invc, "format.indirect.arguments");
}
// TODO: If it is explict array construction, such as "new Object[] {
// ... }", then we could treat it like the VARARGS case, analyzing each
// argument. "new array" is probably rare, in the varargs position.
// fall through
// TODO: If it is explict array construction, such as "new Object[] {
// ... }", then we could treat it like the VARARGS case, analyzing each
// argument. "new array" is probably rare, in the varargs position.
// fall through
case NULLARRAY:
for (ConversionCategory cat : formatCats) {
if (cat == ConversionCategory.NULL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void checkInvocationFormatFor(I18nFormatCall fc) {
}
break;
case NULLARRAY:
// fall-through
// fall-through
case ARRAY:
for (I18nConversionCategory cat : formatCats) {
if (cat == I18nConversionCategory.UNUSED) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ protected boolean commonAssignmentCheck(
|| !((IdentifierTree) receiver).getName().contentEquals("this")) {
return null;
}
// fallthrough
// fallthrough
case IDENTIFIER:
TreePath path = getCurrentPath();
if (TreePathUtil.inConstructor(path)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ public boolean canCreateObligations() {

@Override
@SuppressWarnings("TypeParameterUnusedInFormals") // Intentional abuse
public <T extends GenericAnnotatedTypeFactory<?, ?, ?, ?>> @Nullable T getTypeFactoryOfSubcheckerOrNull(Class<? extends BaseTypeChecker> subCheckerClass) {
public <T extends GenericAnnotatedTypeFactory<?, ?, ?, ?>>
@Nullable T getTypeFactoryOfSubcheckerOrNull(
Class<? extends BaseTypeChecker> subCheckerClass) {
if (subCheckerClass == MustCallChecker.class) {
if (!canCreateObligations()) {
return super.getTypeFactoryOfSubcheckerOrNull(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ tree, getCurrentPath())) {
}
break;
}
// Other plus binary trees should be handled in the default case.
// fall through
// Other plus binary trees should be handled in the default case.
// fall through
default:
if (leftOpType.hasEffectiveAnnotation(Unsigned.class)
&& rightOpType.hasEffectiveAnnotation(Signed.class)) {
Expand Down Expand Up @@ -354,8 +354,8 @@ public Void visitCompoundAssignment(CompoundAssignmentTree tree, Void p) {
}
break;
}
// Other plus binary trees should be handled in the default case.
// fall through
// Other plus binary trees should be handled in the default case.
// fall through
default:
if (varType.hasAnnotation(Unsigned.class) && exprType.hasAnnotation(Signed.class)) {
checker.reportError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
public class TypeVarReturnAnnotated {

public static <T extends TypeVarReturnAnnotated>
@org.checkerframework.checker.initialization.qual.FBCBottom @org.checkerframework.checker.nullness.qual.Nullable T extract() {
@org.checkerframework.checker.initialization.qual.FBCBottom @org.checkerframework.checker.nullness.qual.Nullable T
extract() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ public java.lang.String toString() {

@org.checkerframework.dataflow.qual.SideEffectFree
@java.lang.SuppressWarnings("all")
public static CheckerFrameworkBuilder.@org.checkerframework.common.aliasing.qual.Unique CheckerFrameworkBuilderBuilder builder() {
public static CheckerFrameworkBuilder.@org.checkerframework.common.aliasing.qual.Unique CheckerFrameworkBuilderBuilder
builder() {
return new CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder();
}
}
4 changes: 2 additions & 2 deletions checker/tests/fenum/TestSwitch.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void m() {
int plain = 9; // FenumUnqualified

switch (plain) {
// :: error: (switch.type.incompatible)
// :: error: (switch.type.incompatible)
case annotated:
default:
}
Expand All @@ -24,7 +24,7 @@ void m() {
}

switch (annotated) {
// :: error: (switch.type.incompatible)
// :: error: (switch.type.incompatible)
case 45:
default:
}
Expand Down
4 changes: 2 additions & 2 deletions checker/tests/nullness/java17/SwitchExpressionInvariant.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ void method(
List<@NonNull String> list =
// :: error: (assignment.type.incompatible)
switch (fenum) {
// :: error: (switch.expression.type.incompatible)
// :: error: (switch.expression.type.incompatible)
case 1 -> nonnullStrings;
default -> nullableStrings;
};

List<@Nullable String> list2 =
switch (fenum) {
// :: error: (switch.expression.type.incompatible)
// :: error: (switch.expression.type.incompatible)
case 1 -> nonnullStrings;
default -> nullableStrings;
};
Expand Down
14 changes: 7 additions & 7 deletions checker/tests/nullness/java17/SwitchTestIssue5412.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public String foo1a(MyEnum b) {
case VAL1 -> "1";
case VAL2 -> "2";
case VAL3 -> "3";
// The default case is dead code, so it would be possible for type-checking
// to skip it and not issue this warning. But giving the warning is also
// good.
// The default case is dead code, so it would be possible for type-checking
// to skip it and not issue this warning. But giving the warning is also
// good.
default -> null;
};
// :: error: (return.type.incompatible)
Expand Down Expand Up @@ -82,8 +82,8 @@ public String foo4a(MyEnum b) {
case VAL3:
aString = "c";
break;
// The `default:` case is dead code, so it is acceptable for this method to compile
// without nullness errors.
// The `default:` case is dead code, so it is acceptable for this method to compile
// without nullness errors.
default:
break;
}
Expand All @@ -103,8 +103,8 @@ public String foo4b(MyEnum b) {
case VAL3:
aString = "c";
break;
// The `default:` case is dead code, so it is acceptable for this method to compile
// without nullness errors.
// The `default:` case is dead code, so it is acceptable for this method to compile
// without nullness errors.
default:
aString = null;
break;
Expand Down
12 changes: 6 additions & 6 deletions checker/tests/nullness/java21/NullRedundant.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void test1(Object o) {
case Number n:
System.out.println("Number: " + n);
break;
// :: warning: (nulltest.redundant)
// :: warning: (nulltest.redundant)
case null:
System.out.println("null");
break;
Expand All @@ -25,7 +25,7 @@ void test1(Object o) {
}

switch (o) {
// :: warning: (nulltest.redundant)
// :: warning: (nulltest.redundant)
case null, default:
System.out.println("null");
break;
Expand All @@ -35,27 +35,27 @@ void test1(Object o) {
Object test2(Object o) {
switch (o) {
case Number n -> System.out.println("Number: " + n);
// :: warning: (nulltest.redundant)
// :: warning: (nulltest.redundant)
case null -> System.out.println("null");
default -> System.out.println("anything else");
}
;

switch (o) {
// :: warning: (nulltest.redundant)
// :: warning: (nulltest.redundant)
case null, default -> System.out.println("null");
}

var output =
switch (o) {
case Number n -> "Number: " + n;
// :: warning: (nulltest.redundant)
// :: warning: (nulltest.redundant)
case null -> "null";
default -> "anything else";
};

return switch (o) {
// :: warning: (nulltest.redundant)
// :: warning: (nulltest.redundant)
case null -> "null";
default -> "anything else";
};
Expand Down
10 changes: 5 additions & 5 deletions checker/tests/nullness/java21/NullableSwitchSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static String formatterPatternSwitch1(@Nullable Object obj) {
return switch (obj) {
case Integer i -> obj.toString();
case String s -> String.format("String %s", s);
// :: error: (dereference.of.nullable)
// :: error: (dereference.of.nullable)
case null -> obj.toString();
default -> obj.toString();
};
Expand All @@ -24,9 +24,9 @@ static String formatterPatternSwitch2(@Nullable Object obj) {
return switch (obj) {
case Integer i -> obj.toString();
case String s -> String.format("String %s", s);
// TODO: If obj is null, this case isn't reachable, because a null pointer exception
// happens at the selector expression.
// :: error: (dereference.of.nullable)
// TODO: If obj is null, this case isn't reachable, because a null pointer exception
// happens at the selector expression.
// :: error: (dereference.of.nullable)
default -> obj.toString();
};
}
Expand All @@ -35,7 +35,7 @@ static String formatterPatternSwitch3(@Nullable Object obj) {
return switch (obj) {
case Integer i -> obj.toString();
case String s -> String.format("String %s", s);
// :: error: (dereference.of.nullable)
// :: error: (dereference.of.nullable)
case null, default -> obj.toString();
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ private static void producePDF(String file) {
S extends Store<S>,
T extends TransferFunction<V, S>>
@Nullable Map<String, Object> generateStringOfCFG(
String inputFile,
String method,
String clas,
boolean verbose,
@Nullable Analysis<V, S, T> analysis) {
String inputFile,
String method,
String clas,
boolean verbose,
@Nullable Analysis<V, S, T> analysis) {
ControlFlowGraph cfg = generateMethodCFG(inputFile, clas, method);
if (analysis != null) {
analysis.performAnalysis(cfg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ public AnnotationProvider getAnnotationProvider() {
* @return the type factory of the requested subchecker or null if not found
*/
@SuppressWarnings("TypeParameterUnusedInFormals") // Intentional abuse
public <T extends GenericAnnotatedTypeFactory<?, ?, ?, ?>> @Nullable T getTypeFactoryOfSubcheckerOrNull(Class<? extends BaseTypeChecker> subCheckerClass) {
public <T extends GenericAnnotatedTypeFactory<?, ?, ?, ?>>
@Nullable T getTypeFactoryOfSubcheckerOrNull(
Class<? extends BaseTypeChecker> subCheckerClass) {
return getTypeFactory().getTypeFactoryOfSubcheckerOrNull(subCheckerClass);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2948,7 +2948,7 @@ public void warnAboutIrrelevantJavaTypes(
while (true) {
switch (t.getKind()) {

// Recurse for compound types whose top level is not at the far left.
// Recurse for compound types whose top level is not at the far left.
case ARRAY_TYPE:
t = ((ArrayTypeTree) t).getType();
continue;
Expand All @@ -2959,7 +2959,7 @@ public void warnAboutIrrelevantJavaTypes(
t = ((ParameterizedTypeTree) t).getType();
continue;

// Base cases
// Base cases
case PRIMITIVE_TYPE:
case IDENTIFIER:
maybeReportAnnoOnIrrelevant(t, TreeUtils.typeOf(t), annoTrees);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected static AnnotationFieldType typeMirrorToAnnotationFieldType(TypeMirror
switch (tm.getKind()) {
case BOOLEAN:
return BasicAFT.forType(boolean.class);
// Primitives
// Primitives
case BYTE:
return BasicAFT.forType(byte.class);
case CHAR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1114,19 +1114,19 @@ public void updateAtmWithLub(AnnotatedTypeMirror sourceCodeATM, AnnotatedTypeMir
break;
case WILDCARD:
break;
// throw new BugInCF("This can't happen");
// TODO: This comment is wrong: the wildcard case does get entered.
// Because inferring type arguments is not supported, wildcards won't be
// encountered.
// updateATMWithLUB(
// atf,
// ((AnnotatedWildcardType) sourceCodeATM).getExtendsBound(),
// ((AnnotatedWildcardType) ajavaATM).getExtendsBound());
// updateATMWithLUB(
// atf,
// ((AnnotatedWildcardType) sourceCodeATM).getSuperBound(),
// ((AnnotatedWildcardType) ajavaATM).getSuperBound());
// break;
// throw new BugInCF("This can't happen");
// TODO: This comment is wrong: the wildcard case does get entered.
// Because inferring type arguments is not supported, wildcards won't be
// encountered.
// updateATMWithLUB(
// atf,
// ((AnnotatedWildcardType) sourceCodeATM).getExtendsBound(),
// ((AnnotatedWildcardType) ajavaATM).getExtendsBound());
// updateATMWithLUB(
// atf,
// ((AnnotatedWildcardType) sourceCodeATM).getSuperBound(),
// ((AnnotatedWildcardType) ajavaATM).getSuperBound());
// break;
case ARRAY:
AnnotatedTypeMirror sourceCodeComponent =
((AnnotatedArrayType) sourceCodeATM).getComponentType();
Expand All @@ -1147,11 +1147,11 @@ public void updateAtmWithLub(AnnotatedTypeMirror sourceCodeATM, AnnotatedTypeMir
}
}
break;
// case DECLARED:
// Inferring annotations on type arguments is not supported, so no need to recur on
// generic types. If this was ever implemented, this method would need a
// VisitHistory object to prevent infinite recursion on types such as T extends
// List<T>.
// case DECLARED:
// Inferring annotations on type arguments is not supported, so no need to recur on
// generic types. If this was ever implemented, this method would need a
// VisitHistory object to prevent infinite recursion on types such as T extends
// List<T>.
default:
// ATM only has primary annotations
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,8 @@ public String toString() {
* @param orig the map to copy
* @return a deep copy of the map
*/
private static @Nullable Map<String, IPair<AnnotatedTypeMirror, AnnotatedTypeMirror>> deepCopyMapOfStringToPair(
private static @Nullable Map<String, IPair<AnnotatedTypeMirror, AnnotatedTypeMirror>>
deepCopyMapOfStringToPair(
@Nullable Map<String, IPair<AnnotatedTypeMirror, AnnotatedTypeMirror>> orig) {
if (orig == null) {
return null;
Expand Down
Loading
Loading