Merge branch 'pr-1917'
This commit is contained in:
@ -199,7 +199,7 @@ Please note that if CPD detects duplicated source code, it will exit with status
|
||||
This behavior has been introduced to ease CPD integration into scripts or hooks, such as SVN hooks.
|
||||
|
||||
<table>
|
||||
<tr><td>0</td><td>Everything is fine, now code duplications found</td></tr>
|
||||
<tr><td>0</td><td>Everything is fine, no code duplications found</td></tr>
|
||||
<tr><td>1</td><td>Couldn't understand command line parameters or CPD exited with an exception</td></tr>
|
||||
<tr><td>4</td><td>At least one code duplication has been detected unless '--failOnViolation false' is used.</td></tr>
|
||||
</table>
|
||||
|
@ -25,6 +25,8 @@ Being based on a proper Antlr grammar, CPD can:
|
||||
|
||||
### Fixed Issues
|
||||
|
||||
* core
|
||||
* [#1913](https://github.com/pmd/pmd/issues/1913): \[core] "-help" CLI option ends with status code != 0
|
||||
* doc
|
||||
* [#1896](https://github.com/pmd/pmd/issues/1896): \[doc] Error in changelog 6.16.0 due to not properly closed rule tag
|
||||
* [#1898](https://github.com/pmd/pmd/issues/1898): \[doc] Incorrect code example for DoubleBraceInitialization in documentation on website
|
||||
@ -40,6 +42,7 @@ Being based on a proper Antlr grammar, CPD can:
|
||||
* [#1869](https://github.com/pmd/pmd/pull/1869): \[xml] fix #1666 wrong cdata rule description and examples - [Artem](https://github.com/KroArtem)
|
||||
* [#1892](https://github.com/pmd/pmd/pull/1892): \[lua] \[cpd] Added CPD support for Lua - [Maikel Steneker](https://github.com/maikelsteneker)
|
||||
* [#1908](https://github.com/pmd/pmd/pull/1908): \[doc] Update ruleset filename from deprecated basic.xml to quickstart.xml - [crunsk](https://github.com/crunsk)
|
||||
* [#1917](https://github.com/pmd/pmd/pull/1917): \[core] Add 'no error' return option, and assign it to the cli when the help command is invoked - [Renato Oliveira](https://github.com/renatoliveira)
|
||||
|
||||
{% endtocmaker %}
|
||||
|
||||
|
@ -27,6 +27,7 @@ public final class PMDCommandLineInterface {
|
||||
public static final String NO_EXIT_AFTER_RUN = "net.sourceforge.pmd.cli.noExit";
|
||||
public static final String STATUS_CODE_PROPERTY = "net.sourceforge.pmd.cli.status";
|
||||
|
||||
private static final int NO_ERRORS_STATUS = 0;
|
||||
public static final int ERROR_STATUS = 1;
|
||||
public static final int VIOLATIONS_FOUND = 4;
|
||||
|
||||
@ -41,7 +42,7 @@ public final class PMDCommandLineInterface {
|
||||
if (arguments.isHelp()) {
|
||||
jcommander.usage();
|
||||
System.out.println(buildUsageText(jcommander));
|
||||
setStatusCodeOrExit(ERROR_STATUS);
|
||||
setStatusCodeOrExit(NO_ERRORS_STATUS);
|
||||
}
|
||||
} catch (ParameterException e) {
|
||||
jcommander.usage();
|
||||
|
@ -26,8 +26,9 @@ import com.beust.jcommander.ParameterException;
|
||||
public final class CPDCommandLineInterface {
|
||||
private static final Logger LOGGER = Logger.getLogger(CPDCommandLineInterface.class.getName());
|
||||
|
||||
private static final int DUPLICATE_CODE_FOUND = 4;
|
||||
private static final int NO_ERRORS_STATUS = 0;
|
||||
private static final int ERROR_STATUS = 1;
|
||||
private static final int DUPLICATE_CODE_FOUND = 4;
|
||||
|
||||
public static final String NO_EXIT_AFTER_RUN = "net.sourceforge.pmd.cli.noExit";
|
||||
public static final String STATUS_CODE_PROPERTY = "net.sourceforge.pmd.cli.status";
|
||||
@ -66,7 +67,7 @@ public final class CPDCommandLineInterface {
|
||||
if (arguments.isHelp()) {
|
||||
jcommander.usage();
|
||||
System.out.println(buildUsageText());
|
||||
setStatusCodeOrExit(ERROR_STATUS);
|
||||
setStatusCodeOrExit(NO_ERRORS_STATUS);
|
||||
return;
|
||||
}
|
||||
} catch (ParameterException e) {
|
||||
@ -96,10 +97,10 @@ public final class CPDCommandLineInterface {
|
||||
if (arguments.isFailOnViolation()) {
|
||||
setStatusCodeOrExit(DUPLICATE_CODE_FOUND);
|
||||
} else {
|
||||
setStatusCodeOrExit(0);
|
||||
setStatusCodeOrExit(NO_ERRORS_STATUS);
|
||||
}
|
||||
} else {
|
||||
setStatusCodeOrExit(0);
|
||||
setStatusCodeOrExit(NO_ERRORS_STATUS);
|
||||
}
|
||||
} catch (IOException | RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -95,7 +95,7 @@ public class BinaryDistributionIT {
|
||||
ExecutionResult result;
|
||||
|
||||
result = PMDExecutor.runPMD(tempDir, "-h");
|
||||
result.assertExecutionResult(1, "apex, ecmascript, java, jsp, plsql, pom, vf, vm, wsdl, xml, xsl");
|
||||
result.assertExecutionResult(0, "apex, ecmascript, java, jsp, plsql, pom, vf, vm, wsdl, xml, xsl");
|
||||
|
||||
result = PMDExecutor.runPMDRules(tempDir, srcDir, "src/test/resources/rulesets/sample-ruleset.xml");
|
||||
result.assertExecutionResult(4, "JumbledIncrementer.java:8:");
|
||||
@ -111,8 +111,7 @@ public class BinaryDistributionIT {
|
||||
ExecutionResult result;
|
||||
|
||||
result = CpdExecutor.runCpd(tempDir, "-h");
|
||||
|
||||
result.assertExecutionResult(1, "Supported languages: [apex, cpp, cs, dart, ecmascript, fortran, go, groovy, java, jsp, kotlin, lua, matlab, objectivec, perl, php, plsql, python, ruby, scala, swift, vf]");
|
||||
result.assertExecutionResult(0, "Supported languages: [apex, cpp, cs, dart, ecmascript, fortran, go, groovy, java, jsp, kotlin, lua, matlab, objectivec, perl, php, plsql, python, ruby, scala, swift, vf]");
|
||||
|
||||
result = CpdExecutor.runCpd(tempDir, "--minimum-tokens", "10", "--format", "text", "--files", srcDir);
|
||||
result.assertExecutionResult(4, "Found a 10 line (55 tokens) duplication in the following files:");
|
||||
|
Reference in New Issue
Block a user