Skip to main content

Parse linter output and convert it to GitLab Code Quality report

Project description

GitLab-CQ

Parse linter output and convert it to GitLab Code Quality report.

Supported Linters

Pull Requests for additional linter support are welcome.

Installation

$ python -m pip install -U gitlab-cq

Or use pipx:

$ pipx install gitlab-cq

Usage

There are two ways to use GitLab-CQ: run linter command via. GitLab-CQ or parse linter output from stdin.

Run linter command via. GitLab-CQ:

$ gitlab-cq [--output file_path] [--merge] [--echo] CMD [Arguments]

Parse linter output from stdin:

$ CMD [Arguments] | gitlab-cq [--output file_path] [--merge] [--echo] LINTER

Arguments:

  • CMD:
    • Command to run linter.
  • Arguments:
    • Arguments for linter command.
  • LINTER:
    • Linter name to parse: {ruff, pyright, mypy, gcc, clang-tidy, clang}

Options:

  • --output file_path:
    • Output to file_path.
  • --merge:
    • Merge output to existing JSON file (available if --output is specified).
  • --echo:
    • Echo linter output (available if --output is specified).

Required options for linters

The following options are required for linters when parsing from stdin.
(No need to add the following when the linter runs via. GitLab-CQ, since these options are automatically added.)

  • ruff:
    • --output-format json is required and do not pass --output option.
  • pyright:
    • --outputjson is required.
  • mypy:
    • --output=json is required.

Example

Integration to GitLab CI and save an GitLab CQ artifact:

code quality:
  stage: test
  script:
    # Run linters via. GitLab-CQ and merge output to gl-code-quality-report.json
    - pipx install gitlab-cq
    - gitlab-cq --output gl-code-quality-report.json         ruff check .
    - gitlab-cq --output gl-code-quality-report.json --merge pyright .
    - gitlab-cq --output gl-code-quality-report.json --merge mypy .
    # Parse linter/compiler output and merge to gl-code-quality-report.json
    - gcc -Wall -Wextra -o /dev/null -c main.c 2>&1     | gitlab-cq --output gl-code-quality-report.json --merge gcc
    - clang-tidy -format-style=file -p . --quiet main.c | gitlab-cq --output gl-code-quality-report.json --merge clang-tidy  
  artifacts:
    reports:
      codequality: gl-code-quality-report.json

Author

Yoshiki Matsuda (@yosh-matsuda)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitlab_cq-0.2.1.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitlab_cq-0.2.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file gitlab_cq-0.2.1.tar.gz.

File metadata

  • Download URL: gitlab_cq-0.2.1.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gitlab_cq-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3483dd9639405cc97015419ae211b03d187ffc29a3a629d59ed644be6b70fdcb
MD5 0f1de7f9921edb3bee96423c122f8741
BLAKE2b-256 17c7d001fe09fe58deda070fed9bcc396c06c152a0338d41f72ec249c34cbbda

See more details on using hashes here.

File details

Details for the file gitlab_cq-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: gitlab_cq-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gitlab_cq-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4af508f0ac7ca611cf07b67e8d80f2106ad5535b288b0c49cc83397f82a3edd5
MD5 eda244bfc00ae1393e0489b86771a778
BLAKE2b-256 f61a0c077cad16562cef4e4976193f533f0be803c65daeaacb3adf4c777d3638

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page