Coverage on New Code presumably wrong due to offset by 1 for covered lines

Versions used:

  • Sonarqube: (Developer Edition)
    • jacoco Plugin:
  • JDK + Maven: Docker image maven:3-jdk-8
    • org.sonarsource.scanner.maven:sonar-maven-plugin
    • org.jacoco:jacoco-maven-plugin 0.8.5


  • Coverage import from JaCoCo during Analysis of Java Projects based on Maven
  • Execution environment: GitLab CI/CD


  • The positions of covered lines in the code view are offet by 1 in comparison with the report provided by JaCoCo (observation based on the HTML page provided, not on the XML)
  • Computation of Coverage on New Code is therefore presumably wrong, since lines for New Code are correctly determined

Steps to reproduce:

  • Assumption: Maven Project using the JaCoCo and Sonar-Scanner Plugins is available
  1. Verify Maven Project and safe the generated HTML report for comparison
    mvn verify
  2. Perform SonarQube analysis
    mvn -Dsonar.qualitygate.wait=true sonar:sonar
  3. Compare presentation of covered lines in JaCoCo HTML report and the code view in SonarQube

Hello @joha,

So it appears everything is fine to generate JaCoCo reports, but once loaded in SQ every files are offset by one line, so then JaCoCo info does not match anymore? Interesting!

It doesn’t make sense to reproduce the steps you mentioned as most projects will be ok, I mean this usually works! The issue is likely related to something specific in your context:

  • are you sure about files encoding? I’m referring to the source code here, not the report
  • is there one or several weird characters somewhere in each of your files that could mess with how the file is read?
  • are issues reported on the right line or are they also suffering from this problem?