From b7138b0a7744e31d43c2c16894203cd6debc1514 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Tue, 26 Sep 2023 16:14:24 +0200 Subject: [PATCH] [MNG-7416] Simplify Boolean expressions and returns (#227) Use this link to re-run the recipe: https://app.moderne.io/recipes/builder/SEvWu02zw?organizationId=QXBhY2hlIE1hdmVu Co-authored-by: Moderne --- .../annotations/datamodel/ParameterAnnotationContent.java | 6 +----- .../annotations/scanner/visitors/MojoClassVisitor.java | 2 +- .../javadoc/JavaJavadocMojoDescriptorExtractor.java | 2 +- .../extractor/javadoc/JavaMojoDescriptorExtractorTest.java | 3 +-- .../java/org/apache/maven/script/ant/AntPropertyHelper.java | 2 +- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java index c386c1c2..921e30ad 100644 --- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java +++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java @@ -208,11 +208,7 @@ public boolean equals(Object o) { if (!Objects.equals(defaultValue, that.defaultValue)) { return false; } - if (!Objects.equals(property, that.property)) { - return false; - } - - return true; + return Objects.equals(property, that.property); } @Override diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java index a2a6f558..ea0b2c18 100644 --- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java +++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java @@ -86,7 +86,7 @@ public List findFieldWithAnnotation(Class annotation) { } public List findFieldWithAnnotation(Set annotationClassNames) { - List mojoFieldVisitors = new ArrayList(); + List mojoFieldVisitors = new ArrayList<>(); for (MojoFieldVisitor mojoFieldVisitor : this.fieldVisitors) { Map filedVisitorMap = mojoFieldVisitor.getAnnotationVisitorMap(); diff --git a/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java b/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java index 2c713f0a..aba7cc20 100644 --- a/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java +++ b/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java @@ -510,7 +510,7 @@ private Map extractFieldParameterTags(JavaClass javaClass) { if (superClass != null) { rawParams = extractFieldParameterTags(superClass); } else { - rawParams = new TreeMap(); + rawParams = new TreeMap<>(); } for (JavaField field : javaClass.getFields()) { diff --git a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java index f5cdfe59..047844db 100644 --- a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java +++ b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java @@ -35,7 +35,6 @@ import org.apache.maven.tools.plugin.generator.Generator; import org.apache.maven.tools.plugin.generator.PluginDescriptorFilesGenerator; import org.apache.maven.tools.plugin.util.PluginUtils; -import org.codehaus.plexus.component.repository.ComponentDependency; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.console.ConsoleLogger; import org.codehaus.plexus.util.FileUtils; @@ -87,7 +86,7 @@ private PluginToolsRequest createRequest(String directory) { PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setGoalPrefix("test"); - pluginDescriptor.setDependencies(new ArrayList()); + pluginDescriptor.setDependencies(new ArrayList<>()); return new DefaultPluginToolsRequest(project, pluginDescriptor).setEncoding("UTF-8"); } diff --git a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java index 464cd7ec..7454072d 100644 --- a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java +++ b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java @@ -44,7 +44,7 @@ public class AntPropertyHelper extends PropertyHelper { private Log log; private ExpressionEvaluator exprEvaluator; private MavenProject mavenProject; - private Map artifactMap = new HashMap(); + private Map artifactMap = new HashMap<>(); /** * @deprecated use the other constructor