diff --git a/build.gradle b/build.gradle index 4b4dea5..491e4a2 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { id 'java' id 'maven-publish' - id 'com.diffplug.spotless' version '6.14.0' + id 'com.diffplug.spotless' version '6.25.0' id 'io.github.gradle-nexus.publish-plugin' version '1.3.0' id 'net.ltgt.errorprone' version '3.0.1' } diff --git a/src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java b/src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java index cf7716a..ce126ba 100644 --- a/src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java +++ b/src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java @@ -136,7 +136,7 @@ final class NullSpecAnnotatedTypeFactory /** Constructor that takes all configuration from the provided {@code checker}. */ NullSpecAnnotatedTypeFactory(BaseTypeChecker checker, Util util) { - this(checker, util, checker.hasOption("strict"), /*withOtherWorld=*/ null); + this(checker, util, checker.hasOption("strict"), /* withOtherWorld= */ null); } /** @@ -160,8 +160,6 @@ private NullSpecAnnotatedTypeFactory( addAliasedTypeAnnotation( "org.jspecify.annotations.NullnessUnspecified", nullnessOperatorUnspecified); - addAliasedTypeAnnotation( - "org.jspecify.nullness.NullnessUnspecified", nullnessOperatorUnspecified); // Yes, it's valid to pass declaration annotations to addAliased*Type*Annotation. NULLABLE_ANNOTATIONS.forEach(a -> addAliasedTypeAnnotation(a, unionNull)); @@ -190,7 +188,7 @@ private NullSpecAnnotatedTypeFactory( if (!givenOtherWorld) { withOtherWorld = new NullSpecAnnotatedTypeFactory( - checker, util, !isLeastConvenientWorld, /*withOtherWorld=*/ this); + checker, util, !isLeastConvenientWorld, /* withOtherWorld= */ this); } if (isLeastConvenientWorld) { withLeastConvenientWorld = this; @@ -299,7 +297,7 @@ public boolean isSubtype(AnnotationMirror subAnno, AnnotationMirror superAnno) { @Override protected QualifierKindHierarchy createQualifierKindHierarchy( Collection> qualifierClasses) { - return new DefaultQualifierKindHierarchy(qualifierClasses, /*bottom=*/ MinusNull.class) { + return new DefaultQualifierKindHierarchy(qualifierClasses, /* bottom= */ MinusNull.class) { @Override protected Map> createDirectSuperMap() { DefaultQualifierKind minusNullKind = @@ -622,13 +620,13 @@ private final class NullSpecEqualityComparer extends StructuralEqualityComparer @Override protected boolean checkOrAreEqual(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2) { - Boolean pastResult = visitHistory.get(type1, type2, /*hierarchy=*/ unionNull); + Boolean pastResult = visitHistory.get(type1, type2, /* hierarchy= */ unionNull); if (pastResult != null) { return pastResult; } boolean result = areEqual(type1, type2); - this.visitHistory.put(type1, type2, /*hierarchy=*/ unionNull, result); + this.visitHistory.put(type1, type2, /* hierarchy= */ unionNull, result); return result; } @@ -718,7 +716,7 @@ private final class NullSpecTypeVariableSubstitutor extends TypeVariableSubstitu @Override protected AnnotatedTypeMirror substituteTypeVariable( AnnotatedTypeMirror argument, AnnotatedTypeVariable use) { - AnnotatedTypeMirror substitute = argument.deepCopy(/*copyAnnotations=*/ true); + AnnotatedTypeMirror substitute = argument.deepCopy(/* copyAnnotations= */ true); /* * The isNullExclusiveUnderEveryParameterization check handles cases like @@ -1529,7 +1527,7 @@ protected AnnotationFormatter createAnnotationFormatter() { @Override public String formatAnnotationString( Collection annos, boolean printInvisible) { - return super.formatAnnotationString(annos, /*printInvisible=*/ false); + return super.formatAnnotationString(annos, /* printInvisible= */ false); } }; } @@ -1542,7 +1540,7 @@ protected AnnotatedTypeFormatter createAnnotatedTypeFormatter() { private final class NullSpecAnnotatedTypeFormatter implements AnnotatedTypeFormatter { @Override public String format(AnnotatedTypeMirror type) { - return format(type, /*printVerbose=*/ false); + return format(type, /* printVerbose= */ false); } @Override @@ -1834,10 +1832,7 @@ private void addIfNoAnnotationPresent(AnnotatedTypeMirror type, AnnotationMirror */ private boolean hasNullMarkedOrEquivalent(Element elt) { return getDeclAnnotations(elt).stream() - .anyMatch( - am -> - areSameByName(am, "org.jspecify.annotations.NullMarked") - || areSameByName(am, "org.jspecify.nullness.NullMarked")) + .anyMatch(am -> areSameByName(am, "org.jspecify.annotations.NullMarked")) /* * We assume that ProtoNonnullApi is like NullMarked in that it guarantees that *all* types * are non-null, even those that would require type annotations to annotate (e.g., @@ -1849,10 +1844,7 @@ private boolean hasNullMarkedOrEquivalent(Element elt) { private boolean hasNullUnmarked(Element elt) { return getDeclAnnotations(elt).stream() - .anyMatch( - am -> - areSameByName(am, "org.jspecify.annotations.NullUnmarked") - || areSameByName(am, "org.jspecify.nullness.NullUnmarked")); + .anyMatch(am -> areSameByName(am, "org.jspecify.annotations.NullUnmarked")); } /** @@ -1866,7 +1858,7 @@ private static boolean hasAnnotationInCode(AnnotatedConstruct construct, String @SuppressWarnings("unchecked") // safety guaranteed by API docs private T withMinusNull(T type) { // Remove the annotation from the *root* type, but preserve other annotations. - type = (T) type.deepCopy(/*copyAnnotations=*/ true); + type = (T) type.deepCopy(/* copyAnnotations= */ true); /* * TODO(cpovirk): In the case of a type-variable usage, I feel like we should need to *remove* * any existing annotation but then not *add* minusNull. (This is because of the difference @@ -1881,14 +1873,14 @@ private T withMinusNull(T type) { @SuppressWarnings("unchecked") // safety guaranteed by API docs private T withUnionNull(T type) { // Remove the annotation from the *root* type, but preserve other annotations. - type = (T) type.deepCopy(/*copyAnnotations=*/ true); + type = (T) type.deepCopy(/* copyAnnotations= */ true); type.replaceAnnotation(unionNull); return type; } private AnnotatedDeclaredType createType(TypeElement element) { return (AnnotatedDeclaredType) - AnnotatedTypeMirror.createType(element.asType(), this, /*isDeclaration=*/ false); + AnnotatedTypeMirror.createType(element.asType(), this, /* isDeclaration= */ false); } // Avoid lambdas so that our Predicates can have a useful toString() for logging purposes. @@ -1983,7 +1975,6 @@ private enum Present { "org.jetbrains.annotations.Nullable", "org.jmlspecs.annotation.Nullable", "org.jspecify.annotations.Nullable", - "org.jspecify.nullness.Nullable", "org.json.Nullable", "org.netbeans.api.annotations.common.CheckForNull", "org.netbeans.api.annotations.common.NullAllowed", @@ -2030,7 +2021,6 @@ private enum Present { "org.jetbrains.annotations.NotNull", "org.jmlspecs.annotation.NonNull", "org.jspecify.annotations.NonNull", - "org.jspecify.nullness.NonNull", "org.json.NonNull", "org.netbeans.api.annotations.common.NonNull", "org.springframework.lang.NonNull", diff --git a/src/main/java/com/google/jspecify/nullness/NullSpecStore.java b/src/main/java/com/google/jspecify/nullness/NullSpecStore.java index eab4af7..d854406 100644 --- a/src/main/java/com/google/jspecify/nullness/NullSpecStore.java +++ b/src/main/java/com/google/jspecify/nullness/NullSpecStore.java @@ -30,6 +30,6 @@ final class NullSpecStore extends CFAbstractStore { @Override protected boolean shouldInsert( JavaExpression expr, CFValue value, boolean permitNondeterministic) { - return super.shouldInsert(expr, value, /*permitNondeterministic=*/ true); + return super.shouldInsert(expr, value, /* permitNondeterministic= */ true); } } diff --git a/src/main/java/com/google/jspecify/nullness/NullSpecTransfer.java b/src/main/java/com/google/jspecify/nullness/NullSpecTransfer.java index 13f6aef..171e2f2 100644 --- a/src/main/java/com/google/jspecify/nullness/NullSpecTransfer.java +++ b/src/main/java/com/google/jspecify/nullness/NullSpecTransfer.java @@ -412,7 +412,7 @@ private boolean overwriteGetterFromSetter( argument.getUnderlyingType(), getter, setterCall.getReceiver(), - /*arguments=*/ emptyList()); + /* arguments= */ emptyList()); return overwrite(getterCall, argument, store); } @@ -788,7 +788,7 @@ private boolean isReflectiveRead(MethodInvocationNode node) { private AnnotatedTypeMirror typeWithTopLevelAnnotationsOnly( TransferInput input, Node node) { Set annotations = input.getValueOfSubNode(node).getAnnotations(); - AnnotatedTypeMirror type = createType(node.getType(), atypeFactory, /*isDeclaration=*/ false); + AnnotatedTypeMirror type = createType(node.getType(), atypeFactory, /* isDeclaration= */ false); type.addAnnotations(annotations); return type; } diff --git a/src/main/java/com/google/jspecify/nullness/NullSpecVisitor.java b/src/main/java/com/google/jspecify/nullness/NullSpecVisitor.java index a2d1a67..f8d41d5 100644 --- a/src/main/java/com/google/jspecify/nullness/NullSpecVisitor.java +++ b/src/main/java/com/google/jspecify/nullness/NullSpecVisitor.java @@ -88,7 +88,7 @@ final class NullSpecVisitor extends BaseTypeVisitor