def get_suppressed(self, bug):

        return any([
            suppress for suppress in self.__suppress_info
            if suppress[0] == bug['hash_value'] and suppress[1] == os.path.
            basename(bug['file_path']) and skip_suppress_status(suppress[3])
        ])
Exemple #2
0
def skip_report(report_hash, source_file, report_line, checker_name,
                src_comment_handler=None):
    """
    Returns True if the report was suppressed in the source code, otherwise
    False.
    """
    bug = {'hash_value': report_hash, 'file_path': source_file}
    if src_comment_handler and src_comment_handler.get_suppressed(bug):
        LOG.debug("Suppressed by suppress file: %s:%s [%s] %s", source_file,
                  report_line, checker_name, report_hash)
        return True

    sc_handler = SourceCodeCommentHandler()

    # Check for source code comment.
    src_comment_data = sc_handler.filter_source_line_comments(
        source_file,
        report_line,
        checker_name)

    if len(src_comment_data) == 1:
        status = src_comment_data[0]['status']

        LOG.debug("Suppressed by source code comment.")
        if src_comment_handler:
            file_name = os.path.basename(source_file)
            message = src_comment_data[0]['message']
            src_comment_handler.store_suppress_bug_id(
                report_hash,
                file_name,
                message,
                status)

        if skip_suppress_status(status):
            return True

    elif len(src_comment_data) > 1:
        LOG.warning("Multiple source code comment can be found "
                    "for '%s' checker in '%s' at line %d. "
                    "This bug will not be suppressed!",
                    checker_name, source_file, report_line)
    return False
Exemple #3
0
def skip_report(report_hash, source_file, report_line, checker_name,
                src_comment_handler=None):
    """
    Returns True if the report was suppressed in the source code, otherwise
    False.
    """
    bug = {'hash_value': report_hash, 'file_path': source_file}
    if src_comment_handler and src_comment_handler.get_suppressed(bug):
        LOG.debug("Suppressed by suppress file: %s:%s [%s] %s", source_file,
                  report_line, checker_name, report_hash)
        return True

    sc_handler = SourceCodeCommentHandler(source_file)

    # Check for source code comment.
    src_comment_data = sc_handler.filter_source_line_comments(
        report_line,
        checker_name)

    if len(src_comment_data) == 1:
        status = src_comment_data[0]['status']

        LOG.debug("Suppressed by source code comment.")
        if src_comment_handler:
            file_name = os.path.basename(source_file)
            message = src_comment_data[0]['message']
            src_comment_handler.store_suppress_bug_id(
                report_hash,
                file_name,
                message,
                status)

        if skip_suppress_status(status):
            return True

    elif len(src_comment_data) > 1:
        LOG.warning("Multiple source code comment can be found "
                    "for '%s' checker in '%s' at line %d. "
                    "This bug will not be suppressed!",
                    checker_name, source_file, report_line)
    return False
    def get_suppressed(self, bug):

        return any([suppress for suppress in self.__suppress_info
                    if suppress[0] == bug['hash_value'] and
                    suppress[1] == os.path.basename(bug['file_path']) and
                    skip_suppress_status(suppress[3])])