Unable to import external reports like Code coverage, linters

Hi SonarCloud team,

I am creating a POC to see if we can use SonarCloud on all of our projects. I have run into the below issue and any help will be really appreciated.
We integrated Sonarcloud with our Github Repo for Analysis to be done on per PR as well as entire code base. All the default rules are working. We want to be able to import external reports like Code coverage and various other linters. I’m unable to get it to work. Can you please advice on the steps to be followed?

Regards,
Sangram

Hi @sangram and welcome to the community !

For such cases, you will find useful documentation here for importing external issues : https://sonarcloud.io/documentation/analysis/external-issues/

And here for code coverage : https://sonarcloud.io/documentation/analysis/coverage/

Have you already followed those kind of doc ? If yes, do you have any further questions concerning something particular ?

Thanks.
Mickaël

Hi Mickaël,

I had used those pages and added properties to the .sonarcloud.properties file with no luck. We are using Heroku CI and the sonarcloud project is directly linked to Github. So it is doing automatic Analysis of each pull request.
On the guide pages, it says that external reports cannot be imported. Not sure if that is the case.
https://sonarcloud.io/documentation/automatic-analysis/

I also wanted to check if you have a ticketing system where I can work with someone from the support team closely and resolve this issue?

Thanks,
Sangram

Do I need to add the properties from Analysis Parameters page to the .sonarcloud.properties file as well or just adding the ones you suggested should work?

Regards,
Sangram

I found a number of links which said that importing of code coverage and external reports for Automatic Analysis is not yet supported for SonarCloud.


Is there a way to get all the reports on the SonarCloud dashboard if we decide to not use AutoScan?

Regards,
Sangram

As mentioned in the post that you found and in the official doc, this is not supported if you’re using AutoScan.

If you want coverage and external linter reports, then you need to remove the .sonarcloud.properties file and configure a CI-based analysis (see doc).

Thanks Fabrice…

I did setup this on a test POC and it is adding the code coverage information.
Sonarcloud: https://sonarcloud.io/dashboard?id=SangramTester_depot2

I was to setup per PR analysis and decorating PR and as per this page https://sonarcloud.io/documentation/analysis/pull-request/ I shouldn’t need to do anything. But it didn’t work.

I was able to get the the PR results posted using the https://github.com/marketplace/actions/sonarcloud-scan.

Can you please let me know, if this is the correct flow?

Also we have a paid plan in which one of the repo is already being analyzed with Automatic Analysis. Will just deleting the sonarcloud.properties file in that repo allow me to Configure Analysis on the SonarCloud dashboard? I do not see that option currently at all for the project/repo that is already analyzed.

Regards,
Sangram

Hi Fabrice,

Sorry for another set of questions.

  • Where do I see the results of the external reports on the SonarCloud dashboard?
    I’m importing rubocop report and eslint report using the sonar-project.properties. The reports are getting generated and the properties file has sonar.eslint.reportPaths=report.json and sonar.ruby.rubocop.reportPaths=rubocop-result.json.

Yes indeed, deleting this file will deactivate the automatic analysis.

When you configure import of external reports, you should see the “external” issues along with the other ones in the Issues page. If you don’t see any, this means that:

  • either your code is clean and you have no issue found by the external linters, kudos!
  • or you configuration in the sonar-project.properties file was not done correctly. In this case, you should look into the scanner logs to find if there are warnings about (for instance) JSON files not found. This will help you troubleshoot the situation.

Fabrice,
Just wanted to thank you for your responses. They have been really helpful in pushing through this project.

As mentioned previously, I am using Github Action to post the per PR Analysis, https://github.com/marketplace/actions/sonarcloud-scan.
Seems like it runs as soon as the code is pushed to the PR and does not wait for SonarCloud to finish importing the code overage reports. How do I make the SonarCloud to post on the PR after the CI is done running the tests?

We are using Github and SonarCloud is one of the Authorized Github App.
On the SonarCloud dashboard -> Project -> Administration -> General Settings ->
SCM is empty
Pull Requests -> Integration with Github -> Repository Identifier is empty.

Regards,
Sangram