SonarScan on PR reports old issues

I have a problem with to many issues being reported on a PR scan.
We are using the New Code set to 60 days.
The report states that I have created 86k new lines. (I’m not that productive). And it does not matter if I change a comment or an actual line.

It’s only a problem when we want to merge back into Develop (main branch).
There are no problem if we create a long-running features branch, and branch out from that, make changes, and want to merge back into long-running features branch.

In sonarcloud, on the main branch I see that between 20-09-2023 and 27-10-2023, we went from 42k issues to 83k issues. Before October, activities had Versions and now they don’t. Not sure if that is an problem.

We are running the SonarScanner on Jenkins.

Hey there.

Where are you running the analysis? By that I mean – which CI (Jenkins, CircleCI, Bitbucket Pipelines…)

This sounds like an issue that comes up when a shallow clone is performed before PR analysis.

We are running the SonarScanner on Jenkins.

Thanks! Can you check to see if a Shallow Clone is being performed? You should be able to find all the ways this can be set in these docs for the Jenkins Git plugin (traditional job, declarative, etc…)

We are not using shallow clone.


Do you receive any warnings in the analysis logs?

I have collected these warnings

16:09:47 WARN: Invalid character encountered in file /home/ec2-user/jenkins/workspace/Sonar Analysis for Pull Request/eclub2-custom/SATS/conversion/src/dk/procard/eclub/converter/sats/fi/ at line 61 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.

16:12:11 WARN: Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.

16:12:11 WARN: Use of preview features have been detected during analysis. Enable DEBUG mode to see them.

16:12:11 WARN: No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths=‘target/jacoco.xml’. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml

16:17:31 WARN: Failed to find InputFile for /home/ec2-user/jenkins/workspace/Exerp_Platform_Pipeline_develop/web/src/main/java/dk/procard/eclub/web/util/, check exclusions.

16:18:34 WARN: File ‘/home/ec2-user/jenkins/workspace/Sonar Analysis for Pull Request/server-core-impl/src/main/java/com/exerp/clublead/server/booking/course/’ was detected as changed but without having changed lines

16:19:43 WARN: Found multiple ‘report-task.txt’ in the workspace. Taking the first one.
16:19:43 /home/ec2-user/jenkins/workspace/Sonar Analysis for Pull Request/.scannerwork/report-task.txt
16:19:43 /home/ec2-user/jenkins/workspace/Sonar Analysis for Pull Request/target/sonar/report-task.txt

Now I think we’re getting somewhere.

Does this just show up for one file, or for all files?

It’s only on some/few of the files. Not sure if they contains 80k lines.

Hey there.

I do intend to come back to this thread, but I didn’t have the chance this week.

Thanks, good to hear.