From 84c73ed06b7895a308f9212e0a7eafd068779d05 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Mon, 24 Oct 2005 19:05:32 +0000 Subject: [PATCH] Various docs tweaks; thx to Jarkko Hietaniemin for the suggestions git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3919 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/etc/doing_the_next_pmd_release.txt | 2 +- pmd/src/net/sourceforge/pmd/cpd/CPD.java | 8 +++++--- pmd/src/net/sourceforge/pmd/cpd/CPPTokenizer.java | 1 + pmd/xdocs/cpd.xml | 9 ++++++++- pmd/xdocs/credits.xml | 1 + pmd/xdocs/installing.xml | 3 ++- pmd/xdocs/navigation.xml | 2 +- 7 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pmd/etc/doing_the_next_pmd_release.txt b/pmd/etc/doing_the_next_pmd_release.txt index 6534c513fc..58ba6be3e7 100644 --- a/pmd/etc/doing_the_next_pmd_release.txt +++ b/pmd/etc/doing_the_next_pmd_release.txt @@ -29,7 +29,7 @@ mkdir ~/tmp/pmd-3.3/bin mkdir ~/tmp/pmd-3.3/lib cp ../LICENSE.txt changelog.txt ~/tmp/pmd-3.3/etc cd ../bin/ -cp pmd.* cygwin-run.sh build.xml cpdgui.bat designer.* ~/tmp/pmd-3.3/bin +cp pmd.* cygwin-run.sh build.xml cpd.sh cpdgui.bat designer.* ~/tmp/pmd-3.3/bin cd ../etc/ cp ../lib/pmd-3.3.jar ../lib/xmlParserAPIs-2.6.2.jar ../lib/xercesImpl-2.6.2.jar ../lib/jaxen-1.1-beta-7.jar ~/tmp/pmd-3.3/lib/ mkdir ~/tmp/pmd-3.3/etc/xslt diff --git a/pmd/src/net/sourceforge/pmd/cpd/CPD.java b/pmd/src/net/sourceforge/pmd/cpd/CPD.java index 9e466007de..dc96f58d5d 100644 --- a/pmd/src/net/sourceforge/pmd/cpd/CPD.java +++ b/pmd/src/net/sourceforge/pmd/cpd/CPD.java @@ -90,15 +90,17 @@ public class CPD { try { String lang = LanguageFactory.JAVA_KEY; - Renderer renderer = new SimpleRenderer(); if (args.length > 2) { lang = args[2]; } + LanguageFactory f = new LanguageFactory(); + Language language = f.createLanguage(lang); + + Renderer renderer = new SimpleRenderer(); if (args.length > 3) { renderer = CPD.getRendererFromString(args[3]); } - LanguageFactory f = new LanguageFactory(); - Language language = f.createLanguage(lang); + CPD cpd = new CPD(Integer.parseInt(args[0]), language); cpd.addRecursively(args[1]); cpd.go(); diff --git a/pmd/src/net/sourceforge/pmd/cpd/CPPTokenizer.java b/pmd/src/net/sourceforge/pmd/cpd/CPPTokenizer.java index 7149e90e5a..e44e55af99 100644 --- a/pmd/src/net/sourceforge/pmd/cpd/CPPTokenizer.java +++ b/pmd/src/net/sourceforge/pmd/cpd/CPPTokenizer.java @@ -33,6 +33,7 @@ public class CPPTokenizer implements Tokenizer { tokenEntries.add(TokenEntry.getEOF()); System.out.println("Added " + sourceCode.getFileName()); } catch (TokenMgrError err) { + err.printStackTrace(); System.out.println("Skipping " + sourceCode.getFileName() + " due to parse error"); List emptyCode = new ArrayList(); emptyCode.add(""); diff --git a/pmd/xdocs/cpd.xml b/pmd/xdocs/cpd.xml index e61ff1e860..1b76598f21 100644 --- a/pmd/xdocs/cpd.xml +++ b/pmd/xdocs/cpd.xml @@ -22,7 +22,9 @@

Each rewrite made it much faster, and now it can process the JDK 1.4 java.* packages in about 4 seconds (on my workstation, at least).

Here's a screenshot of CPD after running on the JDK java.lang package.

Note that CPD works with Java, C, C++, and PHP code.

-

If you have Java Web Start, you can run CPD by clicking here.

+

CPD is included with PMD, which you can download here. + Or, if you have Java Web Start, you can run CPD by clicking here. +

Here are the duplicates CPD found in the JDK 1.4 source code.

Here are the duplicates CPD found in the APACHE_2_0_BRANCH branch of Apache (just the httpd-2.0/server/ directory).

@@ -47,6 +49,11 @@ The same guidelines apply.

Also, you can get verbose output from this task by running ant with the -v flag; i.e., ant -v -f mybuildfile.xml cpd.

+

Note that CPD is pretty memory-hungry; you may need to give Java more memory to run it, like this: + +$ java -Xmx512m net.sourceforge.pmd.cpd.CPD 100 /path/to/my/src + +

There's also a JavaSpaces version available for splitting the CPD effort across a farm of machines. I usually post news on that here and the releases are here. This project is pretty much dead, though, since the current code is fast enough to just run it on one machine.

diff --git a/pmd/xdocs/credits.xml b/pmd/xdocs/credits.xml index 208ec569d2..9acd82ae55 100644 --- a/pmd/xdocs/credits.xml +++ b/pmd/xdocs/credits.xml @@ -45,6 +45,7 @@