Add --gitlab option to mh_style and mh_lint#303
Open
LucasDooms wants to merge 1 commit into
Open
Conversation
Produces a gitlab code quality report
pvogt09
reviewed
Jul 30, 2025
pvogt09
left a comment
There was a problem hiding this comment.
I didn't check whether the code actually runs, but it looks like a valuable additional feature and it would be nice to have it integrated in a future version.
|
|
||
| contents = { | ||
| "description" : self.message, | ||
| "check_name" : check_name, |
There was a problem hiding this comment.
Suggested change
| "check_name" : check_name, | |
| "type": "issue", | |
| "check_name" : check_name, | |
| "categories": ["Style"], |
Eventually map categories in https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#data-types to Message.kind?
| def to_gitlab(self): | ||
| rv = {} | ||
| rv["path"] = self.filename if self.filename else "" | ||
| rv["lines"] = {"begin": self.line if self.line else 0} |
There was a problem hiding this comment.
Suggested change
| rv["lines"] = {"begin": self.line if self.line else 0} | |
| if self.col_start and self.col_end: | |
| rv["positions"] = { | |
| "begin": { | |
| "line": self.line if self.line else 0, | |
| "column": self.col_start if self.col_start else 0, | |
| }, | |
| "end": { | |
| "line": self.line if self.line else 0, | |
| "column": self.col_end if self.col_end else 0, | |
| }, | |
| } | |
| else: | |
| rv["lines"] = {"begin": self.line if self.line else 0} |
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 a new output format for the
mh_styleandmh_lintcommands.See https://docs.gitlab.com/ci/testing/code_quality/#code-quality-report-format for the specification.
The new code is adapted from the existing JSON handler with different
to_gitlab()calls, andself.blobis a json list instead of an object.I tested it on gitlab and it seems to work.