Searching tool to detect copies of source code

Discussion in 'Java' started by moi, Nov 22, 2005.

  1. moi

    moi Guest

    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
    moi, Nov 22, 2005
    #1
    1. Advertising

  2. 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
    Ingo R. Homann, Nov 22, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bill turner
    Replies:
    2
    Views:
    1,103
    bill turner
    Jul 19, 2005
  2. Tony Bansten
    Replies:
    1
    Views:
    338
    John Ericson
    Oct 19, 2003
  3. Tony Bansten
    Replies:
    0
    Views:
    277
    Tony Bansten
    Oct 19, 2003
  4. sanjay
    Replies:
    5
    Views:
    656
    James Kanze
    Aug 1, 2008
  5. stumblng.tumblr
    Replies:
    1
    Views:
    186
    stumblng.tumblr
    Feb 4, 2008
Loading...

Share This Page