示例#1
0
    def as_phabricator_lint(self):
        """
        Build the Phabricator LintResult instance
        """
        # Add the level to the issue message
        if self.level == Level.Error:
            # We use the IMPORTANT red block silently
            prefix = "(IMPORTANT) ERROR:"
        else:
            prefix = "WARNING:"
        description = f"{prefix} {self.message}"

        # Add a fix when available
        # Prefix each line with 2 spaces as required by phabricator to trigger a code block
        # with syntax highlighting
        if self.fix is not None:
            fix = "\n".join(f"  {l}" for l in self.fix.splitlines())
            description += f"\n\n  lang={self.language}\n{fix}"

        return LintResult(
            name=self.display_name,
            description=description,
            code=self.check,
            severity=self.level.value,
            path=self.path,
            # Report full file issues on line 1
            line=self.line if self.line is not None else 1,
            char=self.column,
        )
示例#2
0
 def as_phabricator_lint(self):
     """
     Outputs a Phabricator lint result
     """
     return LintResult(
         name=self.message,
         code="infer.{}".format(self.check),
         severity=self.level,
         path=self.path,
         line=self.line,
         char=self.column,
         description="Infer detected an issue on this line",
     )
示例#3
0
 def as_phabricator_lint(self):
     '''
     Outputs a Phabricator lint result
     '''
     return LintResult(
         name=self.message,
         code='infer.{}'.format(self.bug_type),
         severity=self.kind,
         path=self.path,
         line=self.line,
         char=self.column,
         description=self.body,
     )
示例#4
0
 def as_phabricator_lint(self):
     """
     Outputs a Phabricator lint result
     """
     return LintResult(
         name=f"Issue {self.analyzer}",
         description=self.message,
         code=self.check,
         severity=self.level,
         path=self.path,
         line=self.line,
         char=self.column,
     )
示例#5
0
 def as_phabricator_lint(self):
     """
     Build the Phabricator LintResult instance
     """
     return LintResult(
         name=self.analyzer.display_name,
         description=self.message,
         code=self.check,
         severity=self.level.value,
         path=self.path,
         # Report full file issues on line 1
         line=self.line if self.line is not None else 1,
         char=self.column,
     )
 def as_phabricator_lint(self):
     '''
     Outputs a Phabricator lint result
     '''
     description = None
     if self.patch:
         description = 'Replace with :\n\n```{}```'.format(self.patch)
     return LintResult(
         name='C/C++ style issue',
         description=description,
         code='clang-format',
         severity='warning',
         path=self.path,
         line=self.line,
         char=self.column,
     )
示例#7
0
    def as_phabricator_lint(self):
        """
        Outputs a Phabricator lint result
        """
        # If there is the reliability index use it
        message = (
            f"Checker reliability is {self.reliability.value}, meaning that the false positive ratio is {self.reliability.invert}.\n{self.message}"
            if self.reliability != Reliability.Unknown else self.message)

        return LintResult(
            name=message,
            code="coverity.{}".format(self.check),
            severity="error",
            path=self.path,
            line=self.line,
        )
示例#8
0
 def as_phabricator_lint(self):
     """
     Outputs a Phabricator lint result
     """
     description = None
     if self.patch:
         description = "Replace with :\n\n```{}```".format(self.patch)
     return LintResult(
         name="C/C++ style issue",
         description=description,
         code="clang-format",
         severity="warning",
         path=self.path,
         line=self.line,
         char=self.column,
     )
示例#9
0
    def as_phabricator_lint(self):
        '''
        Outputs a Phabricator lint result
        '''
        # If there is the reliability index use it
        message = f'Checker reliability is {self.reliability.value} (false positive risk).\n{self.message}' \
            if self.reliability != Reliability.Unknown \
            else self.message

        return LintResult(
            name=message,
            code='coverity.{}'.format(self.kind),
            severity='error',
            path=self.path,
            line=self.line,
            description=self.body,
        )
示例#10
0
 def as_phabricator_lint(self):
     '''
     Outputs a Phabricator lint result
     '''
     code = self.linter
     name = 'MozLint {}'.format(self.linter.capitalize())
     if self.rule:
         code += '.{}'.format(self.rule)
         name += ' - {}'.format(self.rule)
     return LintResult(
         name=name,
         description=self.message,
         code=code,
         severity=self.level,
         path=self.path,
         line=self.line,
         char=self.column,
     )
示例#11
0
文件: lint.py 项目: tp-tc/code-review
 def as_phabricator_lint(self):
     """
     Outputs a Phabricator lint result
     """
     code = self.linter
     name = "MozLint {}".format(self.linter.capitalize())
     if self.check:
         code += ".{}".format(self.check)
         name += " - {}".format(self.check)
     return LintResult(
         name=name,
         description=self.message,
         code=code,
         severity=self.level,
         path=self.path,
         line=self.line,
         char=self.column,
     )
示例#12
0
    def as_phabricator_lint(self):
        """
        Outputs a Phabricator lint result
        """
        description = self.message

        # Append to description the reliability index if any
        if self.reliability != Reliability.Unknown:
            description += "\nChecker reliability is {0}, meaning that the false positive ratio is {1}.".format(
                self.reliability.value, self.reliability.invert)

        return LintResult(
            name="Clang-Tidy - {}".format(self.check),
            description=description,
            code="clang-tidy.{}".format(self.check),
            severity="warning",
            path=self.path,
            line=self.line,
            char=self.column,
        )
示例#13
0
    def as_phabricator_lint(self):
        '''
        Outputs a Phabricator lint result
        '''
        description = self.message

        # Append to description the reliability index if any
        if self.reliability != Reliability.Unknown:
            description += '\nChecker reliability is {} (false positive risk).'.format(
                self.reliability.value)

        if self.body:
            description += '\n\n > {}'.format(self.body)
        return LintResult(
            name='Clang-Tidy - {}'.format(self.check),
            description=description,
            code='clang-tidy.{}'.format(self.check),
            severity='warning',
            path=self.path,
            line=self.line,
            char=self.char,
        )