Fix checkstyle version drift and API change (#88283)

Fix checkstyle version drift and API change.
This commit is contained in:
Rory Hunter 2022-07-05 21:37:16 +01:00 committed by GitHub
parent a9d19865cb
commit a57e645613
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View file

@ -32,9 +32,9 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
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;
/**
* This is a copy of Checkstyle's {@link com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck},
@ -59,10 +59,10 @@ 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 List<String> skipAnnotations = Collections.singletonList("Generated");
private Set<String> skipAnnotations = Set.of("Generated");
/**
* Setter to specify the visibility scope where Javadoc comments are checked.
@ -89,7 +89,7 @@ public class MissingJavadocTypeCheck extends AbstractCheck {
* @param userAnnotations user's value.
*/
public void setSkipAnnotations(String... userAnnotations) {
skipAnnotations = Arrays.asList(userAnnotations);
skipAnnotations = Arrays.stream(userAnnotations).collect(Collectors.toSet());
}
/**
@ -149,10 +149,7 @@ public class MissingJavadocTypeCheck extends AbstractCheck {
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;
}