[ANN] Duplicate source code detector

A

Adrian Carter

Programmers will often reuse code by copying and pasting,
rather than by building reusable objects. For small amounts of
duplicate code thus created, this is not much of a problem.
However large quantities of duplicate source code make a program
repository bigger than it needs to be. More importantly, the
existence of a block of duplicate code means that changes have
to be made in two places rather than one. And it is easy to forget
about changing second or third copies of a code chunk, which makes
bug creation more likely.

I wrote this program, SpyClones, to assist in remediating source
code in projects where too much copy & paste has been happening.
It hunts for chunks of duplicate code, where the number of lines
in a chunk exceeds some user-defined threshhold. The search can be
conducted within a single file of source code, or within a "virtual
file" composed of many concatenated files. You can get a collection
of files into its buffer by drag & drop or by file browse dialogs.
The matching process, that looks for duplicates lines, ignores
minor differences between lines, like different levels of indenting,
differing numbers of internal blank characters, and differences
between program comments that do not affect program behaviour.
The matching process also ignores lines where the entire line
is a comment.

It will deal with source code written in any programming language.
You configure it for the comment styles of your favourite language
by means of an ini file (no registry entries, no installation reqd).

Duplicate code chunks (clones) are highlighted in a split window
(split vertically or horizontally), with a copy of the source code
in each half-window. The bottom of the window contains a "report"
which lists the line numbers where the pairs of duplicate blocks
begin, and the line counts. Clicking on any entry navigates the
contents of each half-window to the appropriate point.

Download from
http://www.homestead.com/adriancarter/ConvertLabels.html

Adrian Carter
 
J

Jörg Schneider

Adrian Carter wrote:

[SpyClones program description]

Very good, thank you. This is an extremly useful program!

After playing around with it a bit, I have a few suggestions:

- after starting, you could allow the user to drag&drop files into
the main window instead of using File->Multifile Dialog

- the filenames should be on top of the panes and the paths should
be cut out in the middle, so you can see the whole filename
example: c:\program files\directory1\directory2\fil <-- cut off
c:\program files\directory1\...\filename.cpp

- the scrollbar for scrolling both panes is placed a bit errr
unlucky :) Maybe you should remove this scrollbar and just add
a checkbox like 'Lock scrollbars' to use either left or right
scrollbar to scroll both panes

Jörg
 
A

Adrian Carter

Jörg Schneider said:
Adrian Carter wrote:

[SpyClones program description]

Very good, thank you. This is an extremly useful program!

After playing around with it a bit, I have a few suggestions:

- after starting, you could allow the user to drag&drop files into
the main window instead of using File->Multifile Dialog

- the filenames should be on top of the panes and the paths should
be cut out in the middle, so you can see the whole filename
example: c:\program files\directory1\directory2\fil <-- cut off
c:\program files\directory1\...\filename.cpp

- the scrollbar for scrolling both panes is placed a bit errr
unlucky :) Maybe you should remove this scrollbar and just add
a checkbox like 'Lock scrollbars' to use either left or right
scrollbar to scroll both panes

All good suggestions - thankyou. I especially agree with your
comment re scrollbars. I will implement these ideas as time permits.

Adrian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top