Code Quality [STARTER]
If you are using GitLab CI/CD, you can analyze your source code quality using GitLab Code Quality. Code Quality uses Code Climate Engines, which are free and open source. Code Quality doesn’t require a Code Climate subscription.
Going a step further, GitLab can show the Code Quality report right in the merge request widget area:
For instance, consider the following workflow:
- Your backend team member starts a new implementation for making certain feature in your app faster
- With Code Quality reports, they analyze how their implementation is impacting the code quality
- The metrics show that their code degrade the quality in 10 points
- You ask a co-worker to help them with this modification
- They both work on the changes until Code Quality report displays no degradations, only improvements
- You approve the merge request and authorize its deployment to staging
- Once verified, their changes are deployed to production
How it works
First of all, you need to define a job in your
.gitlab-ci.yml file that generates the
Code Quality report artifact.
For more information on how the Code Quality job should look like, check the
example on analyzing a project's code quality.
GitLab then checks this report, compares the metrics between the source and target branches, and shows the information right on the merge request.
Note: If the Code Quality report doesn't have anything to compare to, no information will be displayed in the merge request area. That is the case when you add the Code Quality job in your
.gitlab-ci.ymlfor the very first time. Consecutive merge requests will have something to compare to and the Code Quality report will be shown properly.