Skip to content

Commit c36c533

Browse files
committed
Also allow classes (usually Builders) to have NullUnmarked
1 parent 70ed600 commit c36c533

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/test/groovy/graphql/archunit/JSpecifyAnnotationsCheck.groovy

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class JSpecifyAnnotationsCheck extends Specification {
1717
"graphql.ErrorType",
1818
"graphql.ExceptionWhileDataFetching",
1919
"graphql.ExecutionResult",
20-
"graphql.GraphQL\$Builder",
2120
"graphql.GraphQLContext",
2221
"graphql.GraphQLError",
2322
"graphql.GraphqlErrorBuilder",
@@ -370,21 +369,21 @@ class JSpecifyAnnotationsCheck extends Specification {
370369
when:
371370
def classesMissingAnnotation = classes
372371
.stream()
373-
.filter { !it.isAnnotatedWith("org.jspecify.annotations.NullMarked") }
372+
.filter { !it.isAnnotatedWith("org.jspecify.annotations.NullMarked") && !it.isAnnotatedWith("org.jspecify.annotations.NullUnmarked") }
374373
.map { it.name }
375374
.filter { it -> !JSPECIFY_EXEMPTION_LIST.contains(it) }
376375
.collect()
377376

378377
then:
379378
if (!classesMissingAnnotation.isEmpty()) {
380-
throw new AssertionError("""The following public API and experimental API classes are missing @NullMarked annotation:
379+
throw new AssertionError("""The following public API and experimental API classes are missing a JSpecify annotation:
381380
${classesMissingAnnotation.sort().join("\n")}
382381
383-
Add @NullMarked to these public API classes and add @Nullable annotations where appropriate. See documentation at https://jspecify.dev/docs/user-guide/#nullmarked""")
382+
Add @NullMarked or @NullUnmarked to these public API classes. See documentation at https://jspecify.dev/docs/user-guide/#nullmarked""")
384383
}
385384
}
386385

387-
def "exempted classes should not be annotated with @NullMarked"() {
386+
def "exempted classes should not be annotated with @NullMarked or @NullUnmarked"() {
388387
given:
389388
def classes = new ClassFileImporter()
390389
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
@@ -393,13 +392,13 @@ Add @NullMarked to these public API classes and add @Nullable annotations where
393392
when:
394393
def annotatedButExempted = classes.stream()
395394
.filter { JSPECIFY_EXEMPTION_LIST.contains(it.name) }
396-
.filter { it.isAnnotatedWith("org.jspecify.annotations.NullMarked") }
395+
.filter { it.isAnnotatedWith("org.jspecify.annotations.NullMarked") || it.isAnnotatedWith("org.jspecify.annotations.NullUnmarked") }
397396
.map { it.name }
398397
.collect()
399398

400399
then:
401400
if (!annotatedButExempted.isEmpty()) {
402-
throw new AssertionError("""The following classes are in the JSpecify exemption list but are annotated with @NullMarked:
401+
throw new AssertionError("""The following classes are in the JSpecify exemption list but are annotated with @NullMarked or @NullUnmarked:
403402
${annotatedButExempted.sort().join("\n")}
404403
405404
Please remove them from the exemption list in ${JSpecifyAnnotationsCheck.class.simpleName}.groovy.""")

0 commit comments

Comments
 (0)