Question

I've searched the Internet for a while now and I have not been able to find any free (or cheap) tools/utilities/modules that can analyze a set of Perl files (modules or scripts) and flag duplicate or cloned or copy/pasted code.

I'm better now, but I used to copy and paste sections of code all over the place. I'd like to clean it up and fix my old code duplication, but a little bit of tool help would be appreciated so I won't have to go through all my old code with a fine tooth comb. Plus, manual recognition of this sort of offense is error prone.

Was it helpful?

Solution

Funny a similar question was posted to SO just a few minutes ago.

Here is a link with some tools you may find useful.

Code Comparison and Plagirism Detection

OTHER TIPS

What do you mean by duplicate code? Just character exact matches or semantic matches.

There are several tools like http://pmd.sourceforge.net/ that can detect duplicate code by string matches, this tool is for java but the source matching works on plain text.

If you want semantic matching, like

sub A
{return 1;}

to match

sub B
{
    return 1;
}

Then you'll need something else:(

I have used CCFinder in the past to find sections of code which are duplicates. It works quite well but has an.. interesting interface. It doesn't have native support for perl, but it does have a plaintext option which should work for detection of copy and pasting at least. There is a Windows and Ubuntu solution - Freeware, not open source unfortunately.

Semantic Designs makes a product called Clone Dr. that appears to be able to analyze a large number of language types for cloned sections of code. But it appears that their free evaluation version only works on Java and Cobol.

I just evaluated Simian. It has a 15 day free evaluation period and costs a hundred bucks for a single user license. It doesn't officially support Perl, but it does treat them as plain text and analyzes them anyways. This is a super fast utility! And super easy to use. The report generated from this tool was simple and easy to interpret. I totally approve of this tool. Now I just need to talk to my boss and get him to purchase a license.

Here's another web page listing some clone detection tools:

http://sel.ics.es.osaka-u.ac.jp/cdtools/index-e.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top