No code files were found for analysis for pull request

  • which versions are you using:
    • SonarQube 9.9 Developer Edition
    • SonarScanner for MSBuild 5.0.4
  • how is SonarQube deployed: zip
  • what are you trying to achieve: Pull Request analysis

To replicate the problem, there is one *.cs file changed in the Foo.Bar folder compared to sonar.pullrequest.base however, the code request has ‘No code files were found for analysis.’

Below is the sonar scanner log for the specific folder.

INFO: ------------- Run sensors on module Foo.Bar
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=56ms
INFO: Sensor IaC Kubernetes Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Kubernetes Sensor [iac] (done) | time=33ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Roslyn version: 4.4.0.0
INFO: Language version: CSharp7_3
INFO: Concurrent execution: enabled
INFO: Sensor C# Analysis Log [csharp] (done) | time=1ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor HTML [web]
INFO: Sensor HTML is restricted to changed files only
INFO: Sensor HTML [web] (done) | time=1ms
INFO: Sensor XML Sensor [xml]
INFO: Sensor XML Sensor is restricted to changed files only
INFO: Sensor XML Sensor [xml] (done) | time=20ms
INFO: Sensor TextAndSecretsSensor [text]
INFO: Sensor TextAndSecretsSensor is restricted to changed files only
INFO: Sensor TextAndSecretsSensor [text] (done) | time=633ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=0ms
INFO: Sensor VB.NET Analysis Log [vbnet]
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=0ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
INFO: Sensor CSS Rules [javascript]
INFO: Sensor CSS Rules is restricted to changed files only
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor CSS Rules [javascript] (done) | time=0ms
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=0ms
INFO: Sensor IaC Docker Sensor [iac]
INFO: Sensor IaC Docker Sensor is restricted to changed files only
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Docker Sensor [iac] (done) | time=6ms
INFO: Sensor Serverless configuration file sensor [security]
INFO: 0 Serverless function entries were found in the project
INFO: 0 Serverless function handlers were kept as entrypoints
INFO: Sensor Serverless configuration file sensor [security] (done) | time=1ms
INFO: Sensor AWS SAM template file sensor [security]
INFO: Sensor AWS SAM template file sensor [security] (done) | time=0ms
INFO: Sensor AWS SAM Inline template file sensor [security]
INFO: Sensor AWS SAM Inline template file sensor [security] (done) | time=0ms

Hey there.

Can you first make sure you’re using the latest version of the Scanner for .NET, v5.12?

Done the upgrade, but still seeing the same results.

Thanks.

Are you running this build in a CI / CD environment or locally? If locally, have you made sure that you’ve committed the changed file to your local branch?

It was running in CI/CD environment. We have a Jenkins pipeline that does the followings:

  1. Normal build with MSBuild
  2. SonarQube begin with sonar.pullrequest.branch, sonar.pullrequest.key and sonar.pullrequest.base
  3. Build with MSBuild with SQProjectKey and SQInclusionFilter and SQExclusion
  4. SonarQube end

Can you share the full analysis logs? Feel free to redact information as necessary.

SonarScanner.log (1.5 MB)
Scanner log attached. The module that contains the change in this scan is Application.Schedule.

Hey there.

Based on the logs, it seems there are issues when the scanner tries to collect changed files and lines for your project.

INFO: SCM collecting changed files in the branch
WARN: \\jenkins.mirror\MainSolution.git\objects\.probe-6861a7ba-21da-4a92-a9f8-35c96dbc34e5
java.nio.file.AccessDeniedException: \\jenkins.mirror\MainSolution.git\objects\.probe-6861a7ba-21da-4a92-a9f8-35c96dbc34e5
	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:235)
	at java.base/java.nio.file.Files.newByteChannel(Files.java:371)
	at java.base/java.nio.file.Files.createFile(Files.java:648)
	at org.eclipse.jgit.util.FS$FileStoreAttributes.measureFsTimestampResolution(FS.java:565)
	at org.eclipse.jgit.util.FS$FileStoreAttributes.lambda$3(FS.java:430)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

INFO: Merge base sha1: 93d907a2918a45d10af32209e1c294514fb832e2
INFO: SCM collecting changed files in the branch (done) | time=1103ms
INFO: Indexing files of module 'Application.Schedule'
INFO:   Base dir: C:\Temp\SonarQube\git\Scheduler\Application.Scheduler
INFO:   Source paths: Application.cs, Application.Designer.cs, CommonFindFunctions....
INFO:   Excluded sources: **/*Blending**
INFO: SCM writing changed lines
WARN: \\jenkins.mirror\MainSolution.git\objects\pack\.probe-1ddf2dcc-d631-4ef1-a381-84d0e3f86540
java.nio.file.AccessDeniedException: \\jenkins.mirror\MainSolution.git\objects\pack\.probe-1ddf2dcc-d631-4ef1-a381-84d0e3f86540
	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:235)
	at java.base/java.nio.file.Files.newByteChannel(Files.java:371)
	at java.base/java.nio.file.Files.createFile(Files.java:648)
	at org.eclipse.jgit.util.FS$FileStoreAttributes.measureFsTimestampResolution(FS.java:565)
	at org.eclipse.jgit.util.FS$FileStoreAttributes.lambda$3(FS.java:430)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

The user executing the scan doesn’t seem to have access to view the .git folder within the project.

Can you go into more details about how the git clone is happening to bring your project into the Jenkins pipeline? What could be preventing access to the .git folder?