Lines Error- Sonar Scan Failure for Line Out-of-Range

Hi,

  • Developer Edition
  • Version 9.1
  • Azure devops
  • Swift
  • MacOS M1

We keep getting Sonar error complaining code line out of range. The error message is:

ERROR: Error during SonarScanner execution
ERROR: Error during parsing of the generic coverage report ‘/XXX/XXX/XXX/_work/3/s/sonarqube-generic-coverage.xml’. Look at SonarQube documentation to know the expected XML format.
ERROR: Caused by: Line 44 is out of range in the file AppLinkable/Sources/AppLinkable/AppLinkable.swift (lines: 43)

The code it complains on has only 42 lines, we don’t understand how Sonar would expect line 44.
I get this error not only in this file but also in other files. This is not a persistent error. When I run it without making any changes, it works fine from time to time.
I use Azure Devops as the CI tool. The server it was built on has macos m1 operating system. I run it in pipeline with the following commands.

I never received this error in my other projects where I worked with the same standards and environment.

- script: |
       bash xccov-to-sonarqube-generic.sh Build/Logs/Test/*.xcresult/ > sonarqube-generic-coverage.xml



   - script: |
       rm -rf sonar-reports
       rm -rf reports/*
       cp /XXX/XXX/sonar-project.properties .
       sonar-scanner -Dsonar.host.url=$(SONAR_URL) -Dsonar.login=$(SONAR_KEY) -Dsonar.projectKey=$(SONAR_PROJECT_KEY) -Dsonar.projectName=$(SONAR_PROJECT_NAME) -Dsonar.coverageReportPaths=$(COVERAGE_PATH) -Dsonar.qualitygate.wait=true -Dsonar.exclusions=**/*.xml,**/*.m,**/*.html,/Frameworks/** -Dsonar.cfamily.build-wrapper-output. bypass=true

Is there a solution?

Hi,

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

9.1 → 9.9.2 → 10.2.1 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

Regarding your question, you should review the generic coverage report you’re providing to analysis. It’s where lines: 43 is coming from.

 
HTH,
Ann