JetBrains Space
 

Code Analysis Tool Integration

Last modified: 31 May 2024

If your CI server uses a code analysis tool that supports exporting SARIF formatted reports, you can integrate it with Space to display static code analysis results in Space merge request diffs.

Space HTTP API has a dedicated endpoint that can accept code analysis reports as a sarif formatted .json file generated by a code analysis tool for modified code fragments.

The way you set up the integration depends on your CI server and code analysis tool specifics, however the general principles remain the same:

  • An automated job or pipeline is set up on your CI server to run when a new merge request is created or a commit is pushed to an existing merge request.

  • The job is triggered by a webhook configured on the Space end or, as an alternative, by polling your Space repository for changes in branches using the regular expression refs/merge/(.*?-MR-\\d+)/head which Space creates for each merge request.

  • When triggered, the job receives the branch name, extracts the merge request id, and requests Space API for the source and target commit id's.

  • Finally, the job launches a code analysis tool which is instructed to only analyse new changes. The resulting report is generated as a SARIF formatted file and uploaded to Space.