Skip to content

Add --gitlab option to mh_style and mh_lint#303

Open
LucasDooms wants to merge 1 commit into
florianschanda:masterfrom
LucasDooms:gitlab-code-quality-output
Open

Add --gitlab option to mh_style and mh_lint#303
LucasDooms wants to merge 1 commit into
florianschanda:masterfrom
LucasDooms:gitlab-code-quality-output

Conversation

@LucasDooms

Copy link
Copy Markdown

This adds a new output format for the mh_style and mh_lint commands.
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, and self.blob is a json list instead of an object.

I tested it on gitlab and it seems to work.

Produces a gitlab code quality report

@pvogt09 pvogt09 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread miss_hit_core/errors.py

contents = {
"description" : self.message,
"check_name" : check_name,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread miss_hit_core/errors.py
def to_gitlab(self):
rv = {}
rv["path"] = self.filename if self.filename else ""
rv["lines"] = {"begin": self.line if self.line else 0}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}

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.

2 participants