Merge branch 'bug-1481'
This commit is contained in:
@ -86,8 +86,8 @@ public class CPDCommandLineInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cpd.go();
|
cpd.go();
|
||||||
if (cpd.getMatches().hasNext()) {
|
|
||||||
System.out.println(arguments.getRenderer().render(cpd.getMatches()));
|
System.out.println(arguments.getRenderer().render(cpd.getMatches()));
|
||||||
|
if (cpd.getMatches().hasNext()) {
|
||||||
if (arguments.isFailOnViolation()) {
|
if (arguments.isFailOnViolation()) {
|
||||||
setStatusCodeOrExit(DUPLICATE_CODE_FOUND);
|
setStatusCodeOrExit(DUPLICATE_CODE_FOUND);
|
||||||
} else {
|
} else {
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sourceforge.pmd.cpd;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.contrib.java.lang.system.LogMode;
|
||||||
|
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
|
||||||
|
import org.junit.contrib.java.lang.system.StandardOutputStreamLog;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
|
public class CPDCommandLineInterfaceTest {
|
||||||
|
@Rule
|
||||||
|
public final TestRule restoreSystemProperties = new RestoreSystemProperties();
|
||||||
|
@Rule
|
||||||
|
public final StandardOutputStreamLog log = new StandardOutputStreamLog(LogMode.LOG_ONLY);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmptyResultRendering() {
|
||||||
|
System.setProperty(CPDCommandLineInterface.NO_EXIT_AFTER_RUN, "true");
|
||||||
|
CPDCommandLineInterface.main(new String[] {
|
||||||
|
"--minimum-tokens", "340",
|
||||||
|
"--language", "java",
|
||||||
|
"--files", "src/test/resources/net/sourceforge/pmd/cpd/files/",
|
||||||
|
"--format", "xml"
|
||||||
|
});
|
||||||
|
Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<pmd-cpd/>\n", log.getLog());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,6 +23,6 @@ public class CPDCommandLineInterfaceTest extends BaseCPDCLITest {
|
|||||||
runCPD("--minimum-tokens", "5", "--language", "js", "--files", "src/test/resources/net/sourceforge/pmd/cpd/ts/");
|
runCPD("--minimum-tokens", "5", "--language", "js", "--files", "src/test/resources/net/sourceforge/pmd/cpd/ts/");
|
||||||
|
|
||||||
String out = getOutput();
|
String out = getOutput();
|
||||||
Assert.assertTrue(out.isEmpty());
|
Assert.assertTrue(out.trim().isEmpty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,7 @@ you'll need a java8 runtime environment.
|
|||||||
* [#1470](https://sourceforge.net/p/pmd/bugs/1470/): Error with type-bound lambda
|
* [#1470](https://sourceforge.net/p/pmd/bugs/1470/): Error with type-bound lambda
|
||||||
* [#1478](https://sourceforge.net/p/pmd/bugs/1478/): PMD CLI - Use first language as default if Java is not available
|
* [#1478](https://sourceforge.net/p/pmd/bugs/1478/): PMD CLI - Use first language as default if Java is not available
|
||||||
* [#1485](https://sourceforge.net/p/pmd/bugs/1485/): Analysis of some apex classes cause a stackoverflow error
|
* [#1485](https://sourceforge.net/p/pmd/bugs/1485/): Analysis of some apex classes cause a stackoverflow error
|
||||||
|
* [#1481](https://sourceforge.net/p/pmd/bugs/1481/): no problems found results in blank file instead of empty xml
|
||||||
|
|
||||||
**API Changes:**
|
**API Changes:**
|
||||||
|
|
||||||
@ -152,6 +153,7 @@ you'll need a java8 runtime environment.
|
|||||||
* CPD: If a complete filename is specified, the language dependent filename filter is not applied. This allows
|
* CPD: If a complete filename is specified, the language dependent filename filter is not applied. This allows
|
||||||
to scan files, that are not using the standard file extension. If a directory is specified, the filename filter
|
to scan files, that are not using the standard file extension. If a directory is specified, the filename filter
|
||||||
is still applied and only those files with the correct file extension of the language are scanned.
|
is still applied and only those files with the correct file extension of the language are scanned.
|
||||||
|
* CPD: If no problems found, an empty report will be output instead of nothing. See also [#1481](https://sourceforge.net/p/pmd/bugs/1481/)
|
||||||
* New command line parameter for PMD: `-norulesetcompatibility` - this disables the ruleset factory
|
* New command line parameter for PMD: `-norulesetcompatibility` - this disables the ruleset factory
|
||||||
compatibility filter and fails, if e.g. an old rule name is used in the ruleset.
|
compatibility filter and fails, if e.g. an old rule name is used in the ruleset.
|
||||||
See also [#1360](https://sourceforge.net/p/pmd/bugs/1360/).
|
See also [#1360](https://sourceforge.net/p/pmd/bugs/1360/).
|
||||||
|
Reference in New Issue
Block a user