Add GitLab code quality output format to gdlint - #427
Open
ChrisJr404 wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds the
--format gitlaboption togdlintthat was requested in #336, where you mentioned you'd appreciate someone implementing GitLab report generation directly in gdlint. With it,gdlintcan 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 acodequalityartifact.The default is still
text, so nothing changes for existing users. Passing--format gitlabprints 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--formatvalue exits with code 2 and a short message.Internally I split
_lint_fileso 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,flake8andblackall pass locally.