Fixes #1481 no problems found results in blank file instead of empty xml
This commit is contained in:
@ -86,8 +86,8 @@ public class CPDCommandLineInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cpd.go();
|
cpd.go();
|
||||||
|
System.out.println(arguments.getRenderer().render(cpd.getMatches()));
|
||||||
if (cpd.getMatches().hasNext()) {
|
if (cpd.getMatches().hasNext()) {
|
||||||
System.out.println(arguments.getRenderer().render(cpd.getMatches()));
|
|
||||||
setStatusCodeOrExit(DUPLICATE_CODE_FOUND);
|
setStatusCodeOrExit(DUPLICATE_CODE_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
* java-unusedcode/UnusedLocalVariable
|
* java-unusedcode/UnusedLocalVariable
|
||||||
* [#1484](https://sourceforge.net/p/pmd/bugs/1484/): UnusedLocalVariable - false positive - parenthesis
|
* [#1484](https://sourceforge.net/p/pmd/bugs/1484/): UnusedLocalVariable - false positive - parenthesis
|
||||||
|
* General
|
||||||
|
* [#1481](https://sourceforge.net/p/pmd/bugs/1481/): no problems found results in blank file instead of empty xml
|
||||||
|
|
||||||
**API Changes:**
|
**API Changes:**
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user