예제 #1
0
def handle_suppress(args):
    def update_suppression_comment(run_id, report_id, comment):
        client.unSuppressBug([run_id], report_id)
        client.suppressBug([run_id], report_id, comment)

    def bug_hash_filter(bug_id, filepath):
        filepath = '%' + filepath
        return [
            codeCheckerDBAccess.ttypes.ReportFilter(bugHash=bug_id,
                                                    suppressed=True,
                                                    filepath=filepath),
            codeCheckerDBAccess.ttypes.ReportFilter(bugHash=bug_id,
                                                    suppressed=False,
                                                    filepath=filepath)
        ]

    already_suppressed = 'Bug {} in file {} already suppressed. Use --force!'
    limit = codeCheckerDBAccess.constants.MAX_QUERY_SIZE

    client = setupClient(args.host, args.port, '/')

    run_info = check_run_names(client, [args.name])
    run_id, run_date = run_info.get(args.name)

    if args.output:
        for suppression in client.getSuppressedBugs(run_id):
            suppress_file_handler.write_to_suppress_file(
                args.output, suppression.bug_hash, suppression.file_name,
                suppression.comment)

    elif args.input:
        with open(args.input) as supp_file:
            suppress_data = suppress_file_handler.get_suppress_data(supp_file)

        for bug_id, file_name, comment in suppress_data:
            reports = client.getRunResults(run_id, limit, 0, None,
                                           bug_hash_filter(bug_id, file_name))

            for report in reports:
                if report.suppressed and not args.force:
                    print(already_suppressed.format(bug_id, file_name))
                else:
                    update_suppression_comment(run_id, report.reportId,
                                               comment)

    elif args.bugid:
        reports = client.getRunResults(run_id, limit, 0, None,
                                       bug_hash_filter(args.bugid, args.file))

        for report in reports:
            if args.x:
                client.unSuppressBug([run_id], report.reportId)
            elif report.suppressed and not args.force:
                print(already_suppressed.format(args.bugid, args.file))
            else:
                update_suppression_comment(run_id, report.reportId,
                                           args.comment)
예제 #2
0
    def store_suppress_bug_id(self, bug_id, file_name, comment):

        if self.suppress_file is None:
            return False

        ret = suppress_file_handler.write_to_suppress_file(
            self.suppress_file, bug_id, file_name, comment)
        return ret
예제 #3
0
    def store_suppress_bug_id(self, bug_id, file_name, comment, status):

        if not self.__allow_write:
            return True

        ret = suppress_file_handler.write_to_suppress_file(
            self.suppress_file, bug_id, file_name, comment, status)
        self.__revalidate_suppress_data()
        return ret
    def store_suppress_bug_id(self, bug_id, file_name, comment):

        if self.suppress_file is None:
            return True

        ret = suppress_file_handler.write_to_suppress_file(
            self.suppress_file, bug_id, file_name, comment)
        self.__revalidate_suppress_data()
        return ret