def get_diff_results(client, baseids, cmp_data): report_filter = ttypes.ReportFilter() add_filter_conditions(report_filter, args.filter) # Do not show resolved bugs in compare mode new. if cmp_data.diffType == ttypes.DiffType.NEW: report_filter.detectionStatus = [ ttypes.DetectionStatus.NEW, ttypes.DetectionStatus.UNRESOLVED, ttypes.DetectionStatus.REOPENED ] sort_mode = [(ttypes.SortMode(ttypes.SortType.FILENAME, ttypes.Order.ASC))] limit = constants.MAX_QUERY_SIZE offset = 0 all_results = [] results = client.getRunResults(baseids, limit, offset, sort_mode, report_filter, cmp_data) while results: all_results.extend(results) offset += limit results = client.getRunResults(baseids, limit, offset, sort_mode, report_filter, cmp_data) return all_results
def get_diff_base_results(client, baseids, base_hashes, suppressed_hashes): base_results = [] report_filter = ttypes.ReportFilter() add_filter_conditions(client, report_filter, args) sort_mode = [(ttypes.SortMode( ttypes.SortType.FILENAME, ttypes.Order.ASC))] limit = constants.MAX_QUERY_SIZE offset = 0 report_filter.reportHash = base_hashes + suppressed_hashes results = client.getRunResults(baseids, limit, offset, sort_mode, report_filter, None) while results: base_results.extend(results) offset += limit results = client.getRunResults(baseids, limit, offset, sort_mode, report_filter, None) return base_results
def get_diff_remote_runs(client, basename, newname): """ Compares two remote runs and returns the filtered results. """ report_filter = ttypes.ReportFilter() add_filter_conditions(client, report_filter, args) base_ids, base_run_names, base_run_tags = process_run_arg(basename) report_filter.runTag = base_run_tags cmp_data = ttypes.CompareData() cmp_data.diffType = get_diff_type() new_ids, new_run_names, new_run_tags = process_run_arg(newname) cmp_data.runIds = new_ids cmp_data.runTag = new_run_tags # Do not show resolved bugs in compare mode new. if cmp_data.diffType == ttypes.DiffType.NEW: report_filter.detectionStatus = [ ttypes.DetectionStatus.NEW, ttypes.DetectionStatus.UNRESOLVED, ttypes.DetectionStatus.REOPENED] sort_mode = [(ttypes.SortMode( ttypes.SortType.FILENAME, ttypes.Order.ASC))] limit = constants.MAX_QUERY_SIZE offset = 0 all_results = [] results = client.getRunResults(base_ids, limit, offset, sort_mode, report_filter, cmp_data) while results: all_results.extend(results) offset += limit results = client.getRunResults(base_ids, limit, offset, sort_mode, report_filter, cmp_data) return all_results, base_run_names, new_run_names
def getDiffResults(client, baseids, cmp_data): report_filter = ttypes.ReportFilter() add_filter_conditions(report_filter, args.filter) sort_mode = [(ttypes.SortMode(ttypes.SortType.FILENAME, ttypes.Order.ASC))] limit = constants.MAX_QUERY_SIZE offset = 0 all_results = [] results = client.getRunResults(baseids, limit, offset, sort_mode, report_filter, cmp_data) while results: all_results.extend(results) offset += limit results = client.getRunResults(baseids, limit, offset, sort_mode, report_filter, cmp_data) return all_results
def get_diff_report_dir(client, baseids, report_dir, diff_type): report_filter = ttypes.ReportFilter() add_filter_conditions(report_filter, args.filter) sort_mode = [(ttypes.SortMode(ttypes.SortType.FILENAME, ttypes.Order.ASC))] limit = constants.MAX_QUERY_SIZE offset = 0 base_results = [] results = client.getRunResults(baseids, limit, offset, sort_mode, report_filter, None) while results: base_results.extend(results) offset += limit results = client.getRunResults(baseids, limit, offset, sort_mode, report_filter, None) base_hashes = {} for res in base_results: base_hashes[res.bugHash] = res filtered_reports = [] new_results = get_report_dir_results(report_dir) new_hashes = {} suppressed_in_code = [] for rep in new_results: bughash = rep.main['issue_hash_content_of_line_in_context'] source_file = rep.main['location']['file_name'] bug_line = rep.main['location']['line'] new_hashes[bughash] = rep sp_handler = suppress_handler.SourceSuppressHandler( source_file, bug_line, bughash, rep.main['check_name']) if sp_handler.get_suppressed(): suppressed_in_code.append(bughash) LOG.debug("Bug " + bughash + "is suppressed in code. file:" + source_file + "Line " + str(bug_line)) if diff_type == 'new': # Shows new reports from the report dir # which are not present in the baseline (server) # and not suppressed in the code. for result in new_results: if not (result.main['issue_hash_content_of_line_in_context'] in base_hashes) and \ not (result.main['issue_hash_content_of_line_in_context'] in suppressed_in_code): filtered_reports.append(result) elif diff_type == 'resolved': # Show bugs in the baseline (server) # which are not present in the report dir # or suppressed. for result in base_results: if not (result.bugHash in new_hashes) or \ (result.bugHash in suppressed_in_code): filtered_reports.append(result) elif diff_type == 'unresolved': # Shows bugs in the report dir # that are not suppressed and # which are also present in the baseline (server) for result in new_results: new_hash = result.main['issue_hash_content_of_line_in_context'] if new_hash in base_hashes and \ not (new_hash in suppressed_in_code): filtered_reports.append(result) return filtered_reports