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

Logic for 'New Code' coverage can miss some new code

    Details

      Description

      Overview
      When using differential view with previous analysis, 'coverage on new code' identifies new code based on the date of the previous analysis. This is unreliable and can lead to new code being missed, only because it was committed just before the previous analysis ran (but just after the commit that was being analyzed). Example screenshot missed_new_code.png attached (full details below).

      SonarQube versions: reproduced on 5.2 with Git plugin (v1.1) . Similar behavior on 4.5.6 with SCM Activity plugin (v1.8).

      Scenario (Git + Jenkins + Sonar): (Jenkins just taken as an example)

      • Commit C0 pushed in Git at t0 and checked out by Jenkins (for build + sonar job)
      • Jenkins builds (takes 2 hours)
      • While Jenkins builds, commit C1 is pushed in Git at t1
      • Jenkins finishes building and runs Sonar Scanner (t2, analysis 1)
      • (more commits are pushed in Git)
      • Jenkins starts a new job at t3, builds and runs Sonar Scanner (analysis 2)
      • 'New code' coverage (in differential view) between analysis 2 and 1 will only consider code committed after t2 (date of previous analysis). C1 is therefore ignored and not taken into account for 'Coverage on New Code' !

      Detailed reproduction: pseudo-script with patches attached in new_code_bug.zip . Quite straightforward: two shells, one where a git repo receives commited code, the other acting as CI server (checkout + build + sonar scanning).

      Note: only diff with previous analysis is mentioned here, but it could also be reproduced for other custom periods. Still, for "since previous version", this limitation is unlikely to happen (see comments below).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                nicolas.bontoux Nicolas Bontoux
              • Votes:
                8 Vote for this issue
                Watchers:
                17 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: