Skip to content

Add GitLab code quality output format to gdlint - #427

Open
ChrisJr404 wants to merge 1 commit into
Scony:masterfrom
ChrisJr404:gdlint-gitlab-format
Open

Add GitLab code quality output format to gdlint#427
ChrisJr404 wants to merge 1 commit into
Scony:masterfrom
ChrisJr404:gdlint-gitlab-format

Conversation

@ChrisJr404

Copy link
Copy Markdown

This adds the --format gitlab option to gdlint that was requested in #336, where you mentioned you'd appreciate someone implementing GitLab report generation directly in gdlint. With it, gdlint can emit a GitLab Code Quality report as JSON instead of the usual human-readable text, which lets it drop straight into a GitLab CI pipeline as a codequality artifact.

The default is still text, so nothing changes for existing users. Passing --format gitlab prints a Code Climate style JSON array on stdout (gdlint --format gitlab source/ > gl-code-quality-report.json), with one entry per problem carrying the check name, description, file path, line, a stable md5 fingerprint, and a severity. An unsupported --format value exits with code 2 and a short message.

Internally I split _lint_file so it returns the problems instead of printing them, and moved the text/gitlab reporting into a small helper, so both formats share the same linting path. I added subprocess tests covering the valid/invalid cases, fingerprint uniqueness, and the bad-format path, and updated the README and changelog. pytest, pylint, flake8 and black all pass locally.

Add a --format option to gdlint so it can emit a GitLab Code Quality
report as JSON instead of the human-readable text output. The default
stays 'text', so existing behaviour is unchanged; passing --format gitlab
prints a Code Climate style JSON array on stdout that can be consumed
directly as a codequality artifact in GitLab CI.

Closes Scony#336
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant