Fixed bug 797243 - CPD XML report can no longer contain ]]> (CDEnd)

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2230 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2003-08-29 18:57:38 +00:00
parent 3fba5448d8
commit 8de613644c
4 changed files with 21 additions and 1 deletions

View File

@ -3,6 +3,7 @@ Fixed bug 782246 - FinalFieldCouldBeStatic no longer flags fields in interfaces.
Fixed bug 782235 - "ant -version" now prints more details when a file errors out.
Fixed bug 779874 - LooseCouplingRule no longer triggers on ArrayList
Fixed bug 781393 - VariableNameDeclaration no longer throws ClassCastExpression since ASTLocalVariableDeclaration now subclasses AccessNode
Fixed bug 797243 - CPD XML report can no longer contain ]]> (CDEnd)
Fixed bug - Specifying a non-existing rule format on the command line no longer results in a ClassNotFoundException.
XPath rules may now include pluggable parameters. This feature is very limited. For now.
Tweaked CPD time display field

View File

@ -13,4 +13,8 @@ public class StringUtilTest extends TestCase {
assertEquals("faaaa", StringUtil.replaceString("foo", 'o', "aa"));
}
public void testReplaceStringWithString() {
assertEquals("foo]]>bar", StringUtil.replaceString("foo]]>bar", "]]>", "]]>"));
}
}

View File

@ -1,6 +1,7 @@
package net.sourceforge.pmd.cpd;
import net.sourceforge.pmd.PMD;
import net.sourceforge.pmd.util.StringUtil;
import java.util.Iterator;
@ -44,6 +45,6 @@ public class XMLRenderer implements Renderer
buffer.append("</duplication>");
}
buffer.append("</pmd-cpd>");
return buffer.toString();
return StringUtil.replaceString(buffer.toString(), "]]>", "]]&gt;");
}
}

View File

@ -16,4 +16,18 @@ public class StringUtil {
return desc.toString();
}
public static String replaceString(String inputString, String oldString, String newString) {
StringBuffer desc = new StringBuffer();
int index = inputString.indexOf(oldString);
int last = 0;
while (index != -1) {
desc.append(inputString.substring(last, index));
desc.append(newString);
last = index + oldString.length();
index = inputString.indexOf(oldString, last);
}
desc.append(inputString.substring(last));
return desc.toString();
}
}