From f612dd32c5914caa88e1065a2a1a86fe417e76b5 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Tue, 5 Jul 2022 16:46:57 +0100 Subject: [PATCH 1/3] Fix checkstyle version drift and API change --- .../internal/checkstyle/MissingJavadocTypeCheck.java | 11 +++++------ gradle/build.versions.toml | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java index 60e63e90fcaab..5f6080d7820a2 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java @@ -34,7 +34,9 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Set; import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * This is a copy of Checkstyle's {@link com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck}, @@ -62,7 +64,7 @@ public class MissingJavadocTypeCheck extends AbstractCheck { * Specify the list of annotations that allow missed documentation. * Only short names are allowed, e.g. {@code Generated}. */ - private List skipAnnotations = Collections.singletonList("Generated"); + private Set skipAnnotations = Set.of("Generated"); /** * Setter to specify the visibility scope where Javadoc comments are checked. @@ -89,7 +91,7 @@ public void setExcludeScope(Scope excludeScope) { * @param userAnnotations user's value. */ public void setSkipAnnotations(String... userAnnotations) { - skipAnnotations = Arrays.asList(userAnnotations); + skipAnnotations = Arrays.stream(userAnnotations).collect(Collectors.toSet()); } /** @@ -149,10 +151,7 @@ private boolean shouldCheck(final DetailAST ast) { return customScope.isIn(scope) && (surroundingScope == null || surroundingScope.isIn(scope)) - && (excludeScope == null - || !customScope.isIn(excludeScope) - || surroundingScope != null - && !surroundingScope.isIn(excludeScope)) + && (excludeScope == null || !customScope.isIn(excludeScope) || surroundingScope != null && !surroundingScope.isIn(excludeScope)) && !AnnotationUtil.containsAnnotation(ast, skipAnnotations) && ignorePattern.matcher(outerTypeName).find() == false; } diff --git a/gradle/build.versions.toml b/gradle/build.versions.toml index 40ceeb034cf42..10da3176fbbec 100644 --- a/gradle/build.versions.toml +++ b/gradle/build.versions.toml @@ -11,7 +11,7 @@ apache-rat = "org.apache.rat:apache-rat:0.11" asm = { group = "org.ow2.asm", name="asm", version.ref="asm" } asm-tree = { group = "org.ow2.asm", name="asm-tree", version.ref="asm" } bytebuddy = "net.bytebuddy:byte-buddy:1.12.10" -checkstyle = "com.puppycrawl.tools:checkstyle:10.1" +checkstyle = "com.puppycrawl.tools:checkstyle:10.3" commons-codec = "commons-codec:commons-codec:1.11" commmons-io = "commons-io:commons-io:2.2" docker-compose = "com.avast.gradle:gradle-docker-compose-plugin:0.14.13" From 1280d2866731d1f024bc168ac5cb33957671c055 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Tue, 5 Jul 2022 17:00:38 +0100 Subject: [PATCH 2/3] Imports --- .../gradle/internal/checkstyle/MissingJavadocTypeCheck.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java index 5f6080d7820a2..ba0d5dbd5d5a4 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java @@ -32,8 +32,6 @@ import com.puppycrawl.tools.checkstyle.utils.ScopeUtil; import java.util.Arrays; -import java.util.Collections; -import java.util.List; import java.util.Set; import java.util.regex.Pattern; import java.util.stream.Collectors; From 88e8104ea58c3ce5aa3be909aa4c46ec93cc99ec Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Tue, 5 Jul 2022 17:03:44 +0100 Subject: [PATCH 3/3] Update build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java Co-authored-by: Rene Groeschke --- .../gradle/internal/checkstyle/MissingJavadocTypeCheck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java index ba0d5dbd5d5a4..aa9b0ce2bd4f4 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java @@ -59,7 +59,7 @@ public class MissingJavadocTypeCheck extends AbstractCheck { private Pattern ignorePattern = Pattern.compile("^$"); /** - * Specify the list of annotations that allow missed documentation. + * Specify the set of annotations that allow missed documentation. * Only short names are allowed, e.g. {@code Generated}. */ private Set skipAnnotations = Set.of("Generated");