def parse_issues(self, artifacts, revision): """ Parse issues from a log file content """ assert isinstance(artifacts, dict) def default_check(issue): # Use analyzer name when check is not provided # This happens for analyzers who only have one rule # This logic could become the standard once most analyzers # use that format check = issue.get("check") if check: return check return issue.get("analyzer", self.name) return [ DefaultIssue( analyzer=self, revision=revision, path=issue["path"], line=issue["line"], column=issue["column"], nb_lines=issue.get("nb_lines", 1), level=Level(issue["level"]), check=default_check(issue), message=issue["message"], ) for artifact in artifacts.values() for _, path_issues in artifact.items() for issue in path_issues ]
def __init__( self, analyzer, path, column, level, lineno, linter, message, check, revision, **kwargs, ): # Use analyzer name when check is not provided # This happens for analyzers who only have one rule if check is None: check = analyzer.name super().__init__( analyzer, revision, path, line=( lineno and int(lineno) or 0 ), # mozlint sometimes produce strings here nb_lines=1, check=check, column=column, level=Level(level), message=message, ) self.linter = linter
def mock_clang_tidy_issues(mock_revision, mock_task): """ Build a list of clang-tidy issues """ from code_review_bot import Level return [ ClangTidyIssue( analyzer=mock_task(ClangTidyTask, "mock-clang-tidy"), revision=mock_revision, path="dom/animation/Animation.cpp", line=57, column=46, level=Level("error") if i % 2 else Level("warning"), check="clanck.checker", message="Some Error Message", publish=True, ) for i in range(2) ]
def parse_issues(self, artifacts, revision): return [ ClangTidyIssue( analyzer=self, revision=revision, path=path, line=warning["line"], column=warning["column"], check=warning["flag"], level=Level(warning.get("type", "warning")), message=warning["message"], reliability=Reliability(warning["reliability"]) if "reliability" in warning else Reliability.Unknown, reason=warning.get("reason"), publish=warning.get("publish"), ) for artifact in artifacts.values() for path, items in artifact["files"].items() for warning in items["warnings"] ]