7

I am managing a group of three interns working on a php project. They seem to be not good at refactoring and are using duplicate code in multiple places. I am looking for a tool which I can use to find this duplicate code so I can show them.

This would make my job easier, and the project more elegant and less prone to errors. Any leads?

Linus Fernandes
  • 498
  • 5
  • 30
Abhishek
  • 1,749
  • 9
  • 27
  • 39
  • I think it's a good idea to teach your interns code reuse and stuffs like object oriented programming and design. – Nishant Aug 02 '11 at 07:16
  • You can get better duplicate detection if you choose a clone detector that understands the language you are coding in. Which language are you using? – Ira Baxter Aug 18 '11 at 03:16

3 Answers3

6

PMD is a good tool to find code duplication. Here is a link to the site.

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
Anantha Sharma
  • 9,920
  • 4
  • 33
  • 35
  • 1
    Oldies, goldies. Wanted to find cross-project code duplication, copied all relevant code to a temp. dir., downloaded PMD and ran ./bin/run.sh cpd --minimum-tokens 100 --files /tmp/tmpsrc . Works like a charm! – Tomislav Nakic-Alfirevic Sep 20 '16 at 14:55
0

See our CloneDR tool. It finds duplicate code across large software systems, using compiler-accurate parsing to find matches guided by the language syntax (AST matching), ignoring changes in whitespace and linebreaks. It will find exact duplicates, and near-miss duplicates. For near-duplicates, its reports the differences in the near-misses as parameters; it almost tells you how to code a replacement subroutine for the clones.

CloneDR operates on a variety of languages: C, C++, C#, COBOL, EGL, Java, JavaScript, PHP, Python and many more. Example detection reports for each of these can be found at the link.

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341
0

I like CCFinderX a lot, but it is abandonware.

reinierpost
  • 8,425
  • 1
  • 38
  • 70