Introduction to the pull request analysis
Pull request analysis is available starting in Developer Edition.
A pull request analysis occurs when a pull request is opened and every time a change is pushed to the pull request branch. Analysis results only include issues that have been introduced by the pull request itself. A quality gate on the pull request uses these results to ensure that the code changes introduced are always clean.
The pull request analysis must be integrated into a CI pipeline. For more information, see Integration into your CI pipeline on the SonarQube Server analysis overview page.
The term pull request is used by most repository providers. GitLab, however, uses the term “merge request”. Both terms refer to the same functionality and are handled equivalently in Sonar products. In our documentation, any use of the term pull request applies equally to GitLab merge requests.
Clean as You Code
The Quality Gate of your project is used for the pull request analyses. Only the Quality Gate’s conditions applying to new code metrics are used.
In a pull request analysis, new code is defined as the code that has changed in the pull request branch compared to the target branch. Only issues on new code are reported.
- Due to its mechanism for identifying issues on new code, pull request analysis doesn’t report issues raised at the file level.
- During a pull request analysis, new issues on old code are not reported since only new code issues are reported (For more information, see Issue backdating (new issues on old code) in Issue management solution overview.). It means that the first analysis on the target branch after the merge may report new issues on old code that were not reported by the pull request analysis.
To get valuable results when performing a pull request analysis, the target branch should have been analyzed first.
Quality gate status report (pull request decoration)
The pull request analysis results and quality gate status can be reported directly to your DevOps platform’s interface.
Incremental pull request analysis
To shorten the pull request analysis, different incremental analysis mechanisms are used.
Issue synchronization
SonarQube Server synchronizes issue attributes (status, assignee, change log, comments) between the pull request and the target branch. For more information, see the corresponding section in Issue management solution overview. Note that security hotspots are not synchronized.
Related pages
Was this page helpful?