Valid files reported as unknown in coverage report processing

Hello everyone!
This is my third question related to same issue I am facing for last few months.
I followed same steps mentioned in this link
I successfully generated sonarqube-generic-coverage.xml file using commands mentioned at above link. Below is the snippet from data inside in this file.

<coverage version="1">
    <file path="/Users/maxhina/Documents/Tapcheck/TapCheck/WebManager/Survey Monkey/Model/SMSurveyModels.swift">
    <lineToCover lineNumber="64" covered="false"/>
    <lineToCover lineNumber="65" covered="false"/>
    <lineToCover lineNumber="66" covered="false"/>
    <lineToCover lineNumber="67" covered="false"/>
    <lineToCover lineNumber="68" covered="false"/>
    <lineToCover lineNumber="69" covered="false"/>
    <lineToCover lineNumber="70" covered="false"/>
    <lineToCover lineNumber="79" covered="false"/>
    <lineToCover lineNumber="80" covered="false"/>
    <lineToCover lineNumber="81" covered="false"/>
    <lineToCover lineNumber="89" covered="false"/>
    <lineToCover lineNumber="90" covered="false"/>
    <lineToCover lineNumber="91" covered="false"/>
  </file>
</coverage>

Once azure pipeline completes I see below logs

INFO: Sensor AWS SAM template file sensor [security] (done) | time=73ms
INFO: Sensor AWS SAM Inline template file sensor [security]
INFO: Sensor AWS SAM Inline template file sensor [security] (done) | time=2ms
INFO: Sensor Generic Coverage Report
INFO: Parsing /Users/runner/work/1/s/sonarqube-generic-coverage.xml
INFO: Imported coverage data for 0 files
INFO: Coverage data ignored for 582 unknown files, including:
/TapCheck/Application/AppDelegate.swift
/TapCheck/Application/BaseViewController.swift
/TapCheck/Application/ViewController.swift
/TapCheck/Controllers/Account/Authentication/ForgotPasswordVC.swift
/TapCheck/Controllers/Account/Authentication/SignInVC.swift
INFO: Sensor Generic Coverage Report (done) | time=398ms
INFO: Sensor javabugs [dbd]
INFO: Reading IR files from: /Users/runner/work/1/s/.scannerwork/ir/java
INFO: No IR files have been included for analysis.
INFO: Sensor javabugs [dbd] (done) | time=2ms
INFO: Sensor pythonbugs [dbd]
INFO: Reading IR files from: /Users/runner/work/1/s/.scannerwork/ir/python
INFO: No IR files have been included for analysis.
INFO: Sensor pythonbugs [dbd] (done) | time=4ms
INFO: Sensor JavaSecuritySensor [security]
INFO: Reading type hierarchy from: /Users/runner/work/1/s/.scannerwork/ucfg2/java
INFO: Read 0 type definitions
INFO: Reading UCFGs from: /Users/runner/work/1/s/.scannerwork/ucfg2/java
INFO: No UCFGs have been included for analysis.
INFO: Sensor JavaSecuritySensor [security] (done) | time=13ms
INFO: Sensor CSharpSecuritySensor [security]
INFO: Reading type hierarchy from: /Users/runner/work/1/s/ucfg_cs2
INFO: Read 0 type definitions
INFO: Reading UCFGs from: /Users/runner/work/1/s/ucfg_cs2

Need help/suggesion on below error.
INFO: Coverage data ignored for 582 unknown files, including:
/TapCheck/Application/AppDelegate.swift
/TapCheck/Application/BaseViewController.swift
/TapCheck/Application/ViewController.swift
/TapCheck/Controllers/Account/Authentication/ForgotPasswordVC.swift
/TapCheck/Controllers/Account/Authentication/SignInVC.swift

Regards,
Yasir Khan

Hi Yasir,

A path that starts with / is a path from box root. I suspect there’s not actually a TapCheck directory in your CI agent box root, is there?

I guess you need to drop those leading /s to make the paths relative.

 
HTH,
Ann

Hi Ann,
Thanks for always on my side to sort issues. Can you please tell me, should I replace below path

<file path="/Users/maxhina/Documents/Tapcheck/TapCheck/Application/AppDelegate.swift">

with

  <file path="AppDelegate.swift">

?
Regards,
Yasir

Hi Yasir,

I’m not sure what to tell you. You’ll need to see what configuration options are available on the tools you’re using or do some pre-processing of the report.

 
Ann

Hi Ann,
Below command of tool generates coverage file which always set absolute path.

bash xccov-to-sonarqube-generic.sh Build/Logs/Test/*.xcresult/ > sonarqube-generic-coverage.xml
Even on their sample github project Link, issue was opened by someone releated to this.

Hi,

What do the paths in the original file, Build/Logs/Test/*.xcresult/, look like?

 
Ann

After doing some research I am able to generate relative paths in original generated file i.e sonarqube-generic-coverage.xml file
Like

  <file path="TapCheck/Application/AppDelegate.swift">

same for all other files

Earlier these path were

    <file path="/Users/maxhina/Documents/Tapcheck/TapCheck/Application/AppDelegate.swift">

But now I am facing below error while analysing

INFO: Sensor Generic Coverage Report
INFO: Parsing /Users/runner/work/1/s/sonarqube-generic-coverage.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 44.008s
INFO: Final Memory: 36M/124M
INFO: ------------------------------------------------------------------------
##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
##[error]ERROR: Error during parsing of the generic coverage report '/Users/runner/work/1/s/sonarqube-generic-coverage.xml'. Look at SonarQube documentation to know the expected XML format.
ERROR: Caused by: Line 539 is out of range in the file TapCheck/Controllers/Home/HomeVC.swift (lines: 538)
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
ERROR: Error during parsing of the generic coverage report '/Users/runner/work/1/s/sonarqube-generic-coverage.xml'. Look at SonarQube documentation to know the expected XML format.
ERROR: Caused by: Line 539 is out of range in the file TapCheck/Controllers/Home/HomeVC.swift (lines: 538)
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
##[error]The process '/Users/runner/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.33.1/sonar-scanner/bin/sonar-scanner' failed with exit code 2
Finishing: SonarCloudAnalyze

I even checked line 539 of my HomeVC file but there is nothing wrong anywhere in this file.
For Refernece, I have attached file

Hi,

Congrats on getting this far. Unfortunately, you’ve blocked out the file name. Do you confirm the file is TapCheck/Controllers/Home/HomeVC.swift?

 
Ann

1 Like

Hi,
Yes file name is correct
image

Hi,

Thanks for the verification.

Unfortunately, I need to ask you to create a new thread for the parsing error. As you’re aware, we try to keep it to one topic per thread, and we’ve now migrated from “why are the entries in my coverage report ignored?” to “coverage report parsing errors out on valid line”.

I would create the thread for you by splitting this thread, but it’s not doable cleanly. :frowning:

 
Ann

Hi,
Thanks for updating the title of this thread.
I removed HomeVC path from sonar-coverage report and now coverage report shows up.
This thread helped me alot to generate releated path.
Thanks alot Ann for helping me through out this journey.

Regards,
Yasir