SonarQube Java
  1. SonarQube Java
  2. SONARJAVA-88

Provide the ability to reduce the scope of copy/paste detection to sequence of logical statements

    Details

    • Type: New Feature New Feature
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Duplications
    • Labels:
      None
    • Number of attachments :
      2

      Description

      See attached screenshot: this can be quite annoying to detect duplications on simple Java beans across different projects, as some "patterns" may occur quite offen (ids, keys, name, ...)

      Same issue when using for instance inheritance to inject some SQL requests :

      public interface AbstractSQLObject {
        String findByIdSQL();
        String findAllSQL();
        String insertSQL();
        String updateSQL();
        String deleteSQL();
      }
      

      In such case, all classes implementing the AbstractSQLObject are pure duplications if the content of each SQL request is not taken into account.

        Issue Links

          Activity

          Hide
          Freddy Mallet added a comment -

          In fact we could imagine to provide a mode to prevent detection of duplications involving anything else than logical statements.

          Show
          Freddy Mallet added a comment - In fact we could imagine to provide a mode to prevent detection of duplications involving anything else than logical statements.
          Hide
          Freddy Mallet added a comment -

          I've attached another example where this new mode might be useful (switch-case.jpg).

          Here is the way this new mode could work :

          • Generate a unique hash for each :
            • method signature
            • 'case:' clause

          With this mode we could also imagine to decrease the number of required duplicated lines (10) before firing a duplication.

          Show
          Freddy Mallet added a comment - I've attached another example where this new mode might be useful (switch-case.jpg). Here is the way this new mode could work : Generate a unique hash for each : method signature 'case:' clause With this mode we could also imagine to decrease the number of required duplicated lines (10) before firing a duplication.

            People

            • Assignee:
              Unassigned
              Reporter:
              Fabrice Bellingard
            • Votes:
              5 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: