Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-14929

New Code using a 'reference branch' doesn't detect changed code with git merge workflow

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: To Do
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 9.3
    • Component/s: None
    • Labels:
    • Edition:
      Community
    • Production Notes:
      None

      Description

      To compute the lines changed in branches using a "reference branch", the scanner doesn't actually do a git diff. Instead, it finds the merge base and assumes that any line modified after the merge-base is new (by comparing commit dates). The reason is that the New Code, as it's currently implemented, is always based on a threshold date.

      This works fine when there's a simple fork point between the branch being analyzed and the reference branch. In that situation, any commit added to the branch will be considered as new code, even if more commits are added to the reference branch:

      | * 8d36f5b (master) c2
      * | ed90e9f c1
      |/
      * ffd2d95 
      

      Here ed90e9f is correctly identified as new code.

      However, let's consider the following situation:

      * b589561 (HEAD -> feature) c3
      *   3877051 Merge branch 'master' into feature
      |\
      | * 8d36f5b (master) c2
      * | ed90e9f c1
      |/
      * ffd2d95 
      

      Here, the merge base is 8d36f5b (c2). So ed90e9f (c1) won't be considered as new code, even though it's a commit present in the 'feature' branch and not in master.

      The analysis of pull requests does a git diff so doesn't have this problem.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              duarte.meneses Duarte Meneses
              Votes:
              9 Vote for this issue
              Watchers:
              13 Start watching this issue

                Dates

                Created:
                Updated: