Skip to content

Commit

Permalink
Avoid altering severity based on level on codeclimate output (#2637)
Browse files Browse the repository at this point in the history
Closes: #2609
  • Loading branch information
ssbarnea committed Oct 30, 2022
1 parent 3383579 commit bf049fb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ansiblelint/formatters/__init__.py
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

0 comments on commit bf049fb

Please sign in to comment.