Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid altering severity based on level on codeclimate output #2637

Merged
merged 1 commit into from
Oct 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/ansiblelint/formatters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ def format_result(self, matches: list[MatchError]) -> str:
if match.rule.url:
# https://github.com/codeclimate/platform/issues/68
issue["url"] = match.rule.url
issue["severity"] = self._severity_to_level(match)
issue["severity"] = self._remap_severity(match)
# level is not part of CodeClimate specification, but there is
# no other way to expose that info. We recommend switching to
# SARIF format which is better suited for interoperability.
issue["level"] = match.level
issue["description"] = self.escape(str(match.message))
issue["fingerprint"] = hashlib.sha256(
repr(match).encode("utf-8")
Expand All @@ -174,9 +178,7 @@ def format_result(self, matches: list[MatchError]) -> str:
return json.dumps(result)

@staticmethod
def _severity_to_level(match: MatchError) -> str:
if match.level != "error":
return "info"
def _remap_severity(match: MatchError) -> str:
severity = match.rule.severity

if severity in ["LOW"]:
Expand Down