Enriching your analysis - Overview
In the previous section, you learned how the core features of SonarCloud can improve the quality and security of your code by identifying issues early in the development cycle. Now we will examine three more advanced features that allow you to enrich your analysis results with additional insights. These are test coverage, external analyzers, and branch analysis. Note that these features are only available in projects that use CI-based analysis. They are not available in projects that use automatic analysis.
Checking the test coverage of your code with coverage reporting tools is an essential part of the development process.
SonarCloud lets you set up the automatic importing of test coverage reports produced by your language-specific tools and integrate the results into the SonarCloud analysis results.
By setting up this integration you bring an important additional metric into the mix of your SonarCloud results allowing coverage to be taken into account when calculating quality gates.
To set up test coverage import you need to first set up the test coverage reporting tool for your project. This depends largely on the language that you are using. Once this tool is set up to run on every build, you can configure SonarCloud to import that report and integrate it into the analysis.
In addition to importing coverage reports, SonarCloud can also import reports from external analysis tools such as linters. Importing these reports allows SonarCloud to integrate them into the analysis results, providing you with more insight into the state of your code.
To set up import from external analyzers you need to first set up the external reporting tool for your project. This depends largely on the language and other build tools that you are using. Once this is set up to run on every build, you can configure SonarCloud to import the external analysis report and integrate it into the analysis.
So far we have seen that SonarCloud performs analysis on the main branch of your project and individual pull requests.
But, SonarCloud can also provide analysis of other branches in your repository that are neither the main (that is, default) branch nor pull request branches. This feature can be used if:
- Your project has long-living branches other than the main branch that you want to analyze. For example, a development branch or maintenance branches for older versions.
- Your project use short-lived branches (for example, “feature” branches) to introduce changes to your main branch but you do not use them with a pull request mechanism in a supported CI.
If your project has either of these characteristics, configuring branch analysis will let you have the full benefit of SonarCloud analysis.
For information on Ci-based analysis, see Ci-based Analysis.