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
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