cpd: fixed bug #3523614, preserving the newlines in the XML report
Excluding the transitive xalan dependency and adding the missing saxon-dom dependency, so that we have saxon complete and only one XML library. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7680 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -27,6 +27,7 @@ TODO - Release blockers - Must implement before this release can be finally fini
|
||||
and pmd-java:typeof).
|
||||
|
||||
|
||||
Fixed bug 3523614: newline characters stripped from CPD data in PMD 5.0.0
|
||||
Fixed bug 3516101: InsufficientStringBufferDeclaration fails to parse hex
|
||||
Fixed bug 1503099: InefficientStringBuffering bug false +
|
||||
Fixed bug 3109408: String.InefficientStringBuffering false +
|
||||
|
10
pmd/pom.xml
10
pmd/pom.xml
@ -481,6 +481,10 @@
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<groupId>xerces</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>xalan</artifactId>
|
||||
<groupId>xalan</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -493,6 +497,12 @@
|
||||
<artifactId>saxon</artifactId>
|
||||
<version>9.1.0.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.saxon</groupId>
|
||||
<artifactId>saxon</artifactId>
|
||||
<version>9.1.0.8</version>
|
||||
<classifier>dom</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mozilla</groupId>
|
||||
<artifactId>rhino</artifactId>
|
||||
|
@ -41,10 +41,13 @@ public final class XMLRenderer implements Renderer {
|
||||
try {
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
Transformer transformer = tf.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, System.getProperty("file.encoding"));
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "codefragment");
|
||||
StringWriter writer = new StringWriter();
|
||||
transformer.transform(new DOMSource(doc), new StreamResult(writer));
|
||||
return writer.getBuffer().toString().replaceAll("\n|\r", "");
|
||||
return writer.getBuffer().toString();
|
||||
} catch (TransformerException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
@ -51,10 +51,9 @@ public class XMLRendererTest {
|
||||
List<Match> list = new ArrayList<Match>();
|
||||
Match match = new Match(75, new TokenEntry("public", "/var/Foo.java", 48), new TokenEntry("stuff", "/var/Foo.java", 73));
|
||||
match.setLineCount(6);
|
||||
match.setSourceCodeSlice("code fragment");
|
||||
match.setSourceCodeSlice("code\nfragment");
|
||||
list.add(match);
|
||||
String report = renderer.render(list.iterator());
|
||||
System.out.println(report);
|
||||
try {
|
||||
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(report.getBytes(ENCODING)));
|
||||
NodeList dupes = doc.getElementsByTagName("duplication");
|
||||
@ -73,7 +72,7 @@ public class XMLRendererTest {
|
||||
}
|
||||
if (file != null) assertEquals("73", file.getAttributes().getNamedItem("line").getNodeValue());
|
||||
assertEquals(1, doc.getElementsByTagName("codefragment").getLength());
|
||||
assertEquals("code fragment", doc.getElementsByTagName("codefragment").item(0).getTextContent());
|
||||
assertEquals("code\nfragment", doc.getElementsByTagName("codefragment").item(0).getTextContent());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
|
Reference in New Issue
Block a user