PMD – Finding copied and pasted code
Октябрь 22, 2006 |Без рубрики
PMD – Finding copied and pasted code:
Finding duplicate code
Overview
Duplicate code can be hard to find, especially in a large project. But PMD’s Copy/Paste Detector (CPD) can find it for you! CPD has been through three major incarnations:
- First we wrote it using a variant of Michael Wise’s Greedy String Tiling algorithm (our variant is described here)
- Then it was completely rewritten by Brian Ewins using the Burrows-Wheeler transform
- Finally, it was rewritten by Steve Hawkins to use the Karp-Rabin string matching algorithm.
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, JSP, C, C++, and PHP code.
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).
Ссылки на эту статью
(HTML-BBcode-Plain Text)

Записей: 745 шт.
Комментирование завершено.