Searching tool to detect copies of source code

M

moi

Hello,

what tool provide an help to transform copies of source code into calls
to one common method in java?

Example:

* original

public void drawCellSmooth(int w, int h) {
if (w < 3 || h < 3)
return;

...
}

public void drawCellNormal(int w, int h) {
if (w < 3 || h < 3)
return;

...
}


* result

private boolean checkWidthHeight(int w, int h) {
return (w < 3 || h < 3);
}

public void drawCellSmooth(int w, int h) {
if (checkWidthHeight(w, h))
return;

...
}

public void drawCellNormal(int w, int h) {
if (checkWidthHeight(w, h))
return;

...
}

Other features are searched:
* detection of all the similar number to transform them into constants
* detection of same source code
* detection of almost same source code
- variable name are different
- the code is not exactly the same
* similar class which should be integrated into a hirarchy
* etc...


Any help appreciated
 
I

Ingo R. Homann

Hi,
what tool provide an help to transform copies of source code into calls
to one common method in java?
...
Other features are searched:
* detection of all the similar number to transform them into constants
* detection of same source code
* detection of almost same source code
- variable name are different
- the code is not exactly the same
* similar class which should be integrated into a hirarchy
* etc...

Some "code auditing" tools can find such redundant code, e.g.
"checkstyle". I am not sure if (not to say "I doubt that") they can deal
with different variable names and so on.

I also do not know if (and I doubt that) there are any tools that
"provide an help to transform copies" (semi-)automatically (except in
very easy cases), since this can be done in very different ways
depending on how similar the code really is.

Ciao,
Ingo
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top