Operations 7 min read

Beyond SAST: Integrating Code Quality Checks in GitLab CI/CD

This article explains why GitLab's built‑in SAST focuses solely on security, distinguishes it from code‑quality analysis, and provides two practical ways—using the official Code‑Quality template and integrating custom linters—to add comprehensive code‑quality checks into your CI/CD pipelines.

Ops Development & AI Practice
Ops Development & AI Practice
Ops Development & AI Practice
Beyond SAST: Integrating Code Quality Checks in GitLab CI/CD

Introduction

GitLab CI/CD includes a built‑in SAST scanner that focuses on security vulnerabilities. SAST does not perform general code‑quality analysis such as syntax style, code‑smell detection, or complexity checks. To enforce code quality you must add a separate tool or use GitLab’s Code Quality framework.

SAST vs. Code Quality

SAST – static analysis for security issues (SQL injection, XSS, unsafe dependencies, hard‑coded secrets, etc.).

Code‑Quality testing – static analysis for engineering quality (duplicate code, long functions, high cyclomatic complexity, style violations, etc.).

GitLab Code Quality feature

The Code Quality feature consumes reports that follow the open Code Climate JSON schema. Any linter that can emit a Code Climate‑compatible report can be integrated and displayed in Merge Requests.

Solution 1 – Built‑in template

GitLab provides a ready‑made template Code-Quality.gitlab-ci.yml that runs a Docker image containing the Code Climate engine and language‑specific plugins. Add the template to .gitlab-ci.yml and optionally restrict execution to merge‑request pipelines.

include:
  - template: Code-Quality.gitlab-ci.yml

code_quality:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

The job produces an artifact named codequality. GitLab parses the artifact and shows the findings in the Merge Request UI.

Solution 2 – Custom linters

When a project already uses a specific linter (e.g., pylint, flake8, ESLint), configure the job to run the linter and output a Code Climate report. Example for ESLint:

Install the GitLab formatter in the project: npm install --save-dev eslint-formatter-gitlab Add a CI job that runs ESLint with the formatter and registers the report:

eslint_code_quality:
  stage: test
  image: node:18
  script:
    - npm ci
    - npx eslint "src/**/*.js" -f gitlab
  artifacts:
    reports:
      codequality: gl-code-quality-report.json
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

Any tool that can emit Code Climate JSON (SonarQube, Checkstyle, etc.) can be integrated in the same way by adjusting the script and the report path.

Key considerations

SAST and Code Quality should be run in separate jobs; they address different risk domains.

Code Quality reports are visualized only when the artifacts:reports:codequality keyword is used.

Running the jobs only on merge‑request pipelines reduces unnecessary compute cost.

Conclusion

SAST in GitLab does not cover general code‑quality checks. To achieve full‑stack governance you must add a Code Quality analysis step, either by using the built‑in Code-Quality.gitlab-ci.yml template or by integrating your own linters that output Code Climate JSON. This ensures that security and maintainability are enforced early in the development workflow.

CI/CDGitLabSAST
Ops Development & AI Practice
Written by

Ops Development & AI Practice

DevSecOps engineer sharing experiences and insights on AI, Web3, and Claude code development. Aims to help solve technical challenges, improve development efficiency, and grow through community interaction. Feel free to comment and discuss.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.