This is an automated email from the ASF dual-hosted git repository.
buhhunyx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new f1ef4ca maven-plugins: fix PMD rule: UnusedAssignment
f1ef4ca is described below
commit f1ef4ca9c4a7d99b6d846b6401410ca3eb637cc2
Author: Alexey Markevich <[email protected]>
AuthorDate: Sun Mar 7 22:23:11 2021 +0300
maven-plugins: fix PMD rule: UnusedAssignment
---
.../cxf/maven_plugin/AbstractCodegenMojo.java | 7 +++---
.../java2swagger/Java2SwaggerMojo.java | 2 +-
.../cxf/maven_plugin/javatowadl/Java2WADLMojo.java | 14 +++++++-----
.../wadlto/AbstractCodeGeneratorMojo.java | 2 +-
.../apache/cxf/maven_plugin/WSDLValidatorMojo.java | 26 +++++++++-------------
5 files changed, 24 insertions(+), 27 deletions(-)
diff --git
a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMojo.java
b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMojo.java
index 65cce43..fdbc84c 100644
---
a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMojo.java
+++
b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMojo.java
@@ -615,7 +615,7 @@ public abstract class AbstractCodegenMojo extends
AbstractMojo {
setJvmForkArgs(javaPath);
cmd.createArg().setLine(additionalJvmArgs);
- File file = null;
+ final File file;
try {
// file = new File("/tmp/test.jar");
file = FileUtils.createTempFile("cxf-codegen", ".jar");
@@ -646,7 +646,7 @@ public abstract class AbstractCodegenMojo extends
AbstractMojo {
String tmpFilePath = file.getAbsolutePath();
if (tmpFilePath.contains(" ")) {
//ensure the path is in double quotation marks if the path
contain space
- tmpFilePath = "\"" + tmpFilePath + "\"";
+ tmpFilePath = '"' + tmpFilePath + '"';
}
cmd.createArg().setValue(tmpFilePath);
@@ -947,10 +947,9 @@ public abstract class AbstractCodegenMojo extends
AbstractMojo {
}
private Artifact findWsdlArtifact(Artifact targetArtifact,
Collection<Artifact> artifactSet) {
- boolean artifactMatched = false;
if (artifactSet != null && !artifactSet.isEmpty()) {
for (Artifact pArtifact : artifactSet) {
- artifactMatched = isArtifactMatched(targetArtifact, pArtifact);
+ boolean artifactMatched = isArtifactMatched(targetArtifact,
pArtifact);
if (targetArtifact.getClassifier() != null &&
pArtifact.getClassifier() != null
&&
targetArtifact.getClassifier().equals(pArtifact.getClassifier())
&& artifactMatched) {
diff --git
a/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
b/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
index 8e49436..eeefa9b 100644
---
a/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
+++
b/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
@@ -195,7 +195,7 @@ public class Java2SwaggerMojo extends AbstractMojo {
// Put the json in target/generated/json
// put the yaml in target/generated/yaml
- String name = null;
+ final String name;
if (outputFileName != null) {
name = outputFileName;
} else if (resourceClasses.size() == 1) {
diff --git
a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
index fc9def9..bea9f51 100644
---
a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
+++
b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
@@ -248,10 +248,10 @@ public class Java2WADLMojo extends AbstractMojo {
if (wadlGenerator == null) {
wadlGenerator = new WadlGenerator(getBus());
}
- DocumentationProvider documentationProvider = null;
if (docProvider != null) {
try {
- documentationProvider =
(DocumentationProvider)getClassLoader().loadClass(docProvider).
+ DocumentationProvider documentationProvider =
+
(DocumentationProvider)getClassLoader().loadClass(docProvider).
getConstructor(new Class[] {String.class}).
newInstance(new Object[]
{project.getBuild().getDirectory()});
wadlGenerator.setDocumentationProvider(documentationProvider);
@@ -262,7 +262,9 @@ public class Java2WADLMojo extends AbstractMojo {
setExtraProperties(wadlGenerator);
StringBuilder sbMain = wadlGenerator.generateWADL(getBaseURI(),
classResourceInfos, useJson, null, null);
- getLog().debug("the wadl is =====> \n" + sbMain.toString());
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("the wadl is =====> \n" + sbMain.toString());
+ }
generateWadl(resourceClasses, sbMain.toString());
}
@@ -295,7 +297,7 @@ public class Java2WADLMojo extends AbstractMojo {
if (outputFile == null && project != null) {
// Put the wadl in target/generated/wadl
- String name = null;
+ final String name;
if (outputFileName != null) {
name = outputFileName;
} else if (resourceClasses.size() == 1) {
@@ -303,8 +305,8 @@ public class Java2WADLMojo extends AbstractMojo {
} else {
name = "application";
}
- outputFile = (project.getBuild().getDirectory() +
"/generated/wadl/" + name + "."
- + outputFileExtension).replace("/", File.separator);
+ outputFile = (project.getBuild().getDirectory() +
"/generated/wadl/" + name + '.'
+ + outputFileExtension).replace('/', File.separatorChar);
}
try {
diff --git
a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
index bf9119a..c29f661 100644
---
a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
+++
b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
@@ -455,7 +455,7 @@ public abstract class AbstractCodeGeneratorMojo extends
AbstractMojo {
cmd.createArg().setLine(additionalJvmArgs);
- File file = null;
+ final File file;
try {
//file = new File("/tmp/test.jar");
file = FileUtils.createTempFile("cxf-codegen", ".jar");
diff --git
a/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java
b/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java
index a10e819..c66f22b 100644
---
a/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java
+++
b/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java
@@ -124,36 +124,32 @@ public class WSDLValidatorMojo extends AbstractMojo {
List<String> list = new ArrayList<>();
// verbose arg
- if (verbose != null && verbose.booleanValue()) {
+ if (verbose != null && verbose) {
list.add("-verbose");
}
// quiet arg
- if (quiet != null && quiet.booleanValue()) {
+ if (quiet != null && quiet) {
list.add("-quiet");
}
getLog().debug("Calling wsdlvalidator with args: " + list);
- try {
+ final boolean ok;
+ try (InputStream toolspecStream = WSDLValidator.class
.getResourceAsStream("wsdlvalidator.xml")) {
list.add(file.getCanonicalPath());
- String[] pargs = list.toArray(new String[0]);
-
- ToolSpec spec = null;
- try (InputStream toolspecStream = WSDLValidator.class
.getResourceAsStream("wsdlvalidator.xml")) {
- spec = new ToolSpec(toolspecStream, false);
- }
- WSDLValidator validator = new WSDLValidator(spec);
- validator.setArguments(pargs);
- boolean ok = validator.executeForMaven();
- if (!ok) {
- throw new MojoExecutionException("WSDL failed validation:
" + file.getName());
- }
+
+ WSDLValidator validator = new WSDLValidator(new
ToolSpec(toolspecStream, false));
+ validator.setArguments(list.toArray(new String[0]));
+ ok = validator.executeForMaven();
doneFile.createNewFile();
} catch (Throwable e) {
throw new MojoExecutionException(file.getName() + ": "
+ e.getMessage(), e);
}
+ if (!ok) {
+ throw new MojoExecutionException("WSDL failed validation: " +
file.getName());
+ }
}
}