Imported coverage data for 0 files

swift
scanner
(Gash Teshome) #1

When running code coverage analysis on our CI/CD platform (Jenkins worker on macOS) a Swift iOS app, sonar-scanner does not import coverage data with the message

Imported coverage data for 0 files

The same analysis works on developer workstations that are using the same version of sonar-scanner, Java, and OS. I am looking for troubleshooting pointers on how to determine why the same coverage analysis is behaving differently on different systems.

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube: 7.7 Developer Edition
    sonar-scanner: 3.3.0.1492
    SonarSwift plugin: 4.1 (build 3087)
    Java: Java 1.8.0_212 AdoptOpenJDK (64-bit)
    OS: Mac OS X 10.14.3 x86_64
  • what are you trying to achieve
    Code coverage analysis
  • what have you tried so far to achieve this
    We followed the instructions on https://github.com/SonarSource/sonar-scanning-examples/tree/master/swift-coverage. sonar-scanner fails to import coverage data with the sonar-coverage-example code as well as our iOS application. The full output of the analysis for sonar-coverage-example is below. I can also provide the output for a successful analysis, if needed.
sonar-scanner -Dsonar.projectKey=TestCoverage -Dsonar.sources=. -Dsonar.coverageReportPaths=sonarqube-generic-coverage.xml -Dsonar.cfamily.build-wrapper-output.bypass=true
INFO: Scanner configuration file: /usr/local/Cellar/sonar-scanner/3.3.0.1492/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: /private/var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/sonar-project.properties
INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_212 AdoptOpenJDK (64-bit)
INFO: Mac OS X 10.14.3 x86_64
INFO: User cache: /var/jenkins/.sonar/cache
INFO: SonarQube server 7.7.0
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=495ms
INFO: Server id: XXXXXXXXXXXX
INFO: User cache: /var/jenkins/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=122ms
INFO: Load/download plugins (done) | time=168ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=2ms
INFO: Project key: TestCoverage
INFO: Base dir: /private/var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example
INFO: Working dir: /private/var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/.scannerwork
INFO: Load project settings for component key: 'TestCoverage'
INFO: Load project settings for component key: 'TestCoverage' (done) | time=88ms
INFO: Load project branches
INFO: Load project branches (done) | time=86ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=84ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=3ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=131ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=107ms
INFO: Load active rules
INFO: Load active rules (done) | time=2120ms
INFO: Indexing files...
INFO: Project configuration:
INFO: 14 files indexed
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for swift: Sonar way
INFO: ------------- Run sensors on module swift-coverage-example
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=89ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=4ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=1ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=13ms
INFO: Sensor SonarSwift [swift]
INFO: 3 source files to be analyzed
INFO: Parse coverage report (sonarqube-generic-coverage.xml)
INFO: 3/3 source files have been analyzed
INFO: Sensor SonarSwift [swift] (done) | time=1247ms
INFO: Sensor Generic Coverage Report
INFO: Parsing /private/var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/sonarqube-generic-coverage.xml
INFO: Imported coverage data for 0 files
INFO: Coverage data ignored for 3 unknown files, including:
/var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/swift-coverage-example/AppDelegate.swift
/var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/swift-coverage-example/AppDelegate2.swift
/var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/swift-coverage-exampleTests/swift_coverage_exampleTests.swift
INFO: Sensor Generic Coverage Report (done) | time=16ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=13ms
INFO: 1 file had no CPD blocks
INFO: Calculating CPD for 2 files
INFO: CPD calculation finished
INFO: Analysis report generated in 100ms, dir size=105 KB
INFO: Analysis report compressed in 40ms, zip size=19 KB
INFO: Analysis report uploaded in 163ms
INFO: ANALYSIS SUCCESSFUL, you can browse https://sonarqube.pgi-tools.com/dashboard?id=TestCoverage
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarqube.pgi-tools.com/api/ce/task?id=AWp0RE55UBEbit-jKZix
INFO: Analysis total time: 7.705 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 9.858s
INFO: Final Memory: 20M/240M
INFO: ------------------------------------------------------------------------
(G Ann Campbell) #2

Hi,

You stopped reading just a little bit early. :slight_smile:

Just after the line you quote, is the crux:

Your generic test coverage report gives coverage data for files the analysis doesn’t recognize. Are you sure these paths are correct? Also, the third file listed appears itself to be a test. Since you can’t have coverage of tests, that one should probably be dropped from the report.

 
Ann

(Gash Teshome) #3

The files are definitely there:

 ls -l /var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/swift-coverage-exampleTests/swift_coverage_exampleTests.swift 
-rw-r--r--  1 jenkins  wheel  959 May  8 17:15 /var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/swift-coverage-exampleTests/swift_coverage_exampleTests.swift
ls -l /var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/swift-coverage-example/AppDelegate.swift
-rw-r--r--  1 jenkins  wheel  700 May  8 17:15 /var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/swift-coverage-example/AppDelegate.swift
ls -l /var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/swift-coverage-example/AppDelegate2.swift 
-rw-r--r--  1 jenkins  wheel  298 May  8 17:15 /var/jenkins/src/sonar-scanning-examples/swift-coverage/swift-coverage-example/swift-coverage-example/AppDelegate2.swift

I had seen the message about about sonar-scanner not recognizing the files but that is another point where I am confused. If I take the same code and run it on another system with the same versions of sonar-scanner, Java, and OS, the analysis completes successfully.

Are there further troubleshooting steps I can take to see what’s happening in more detail with the analysis? I see that there’s a .scannerwork directory, as well as ~/.sonar/. Is there anything in either directory I can look to understand what’s happening during analysis?

(G Ann Campbell) #4

Hi,

-Dsonar.verbose=true might help.

 
Ann