def _create_diag(message, fmap, files): """ Creates a new plist diagnostic from a single clang-tidy message. """ diag = {} diag['location'] = PListConverter._create_location(message, fmap) diag['check_name'] = message.checker diag['description'] = message.message diag['category'] = PListConverter._get_checker_category( message.checker) diag['type'] = 'clang-tidy' diag['path'] = [] PListConverter._add_fixits(diag, message, fmap) PListConverter._add_notes(diag, message, fmap) # The original message should be the last part of the path. This is # displayed by quick check, and this is the main event displayed by # the web interface. FIXME: notes and fixits should not be events. diag['path'].append(PListConverter._create_event_from_note(message, fmap)) diag['issue_hash_content_of_line_in_context'] \ = generate_report_hash(diag['path'], files[diag['location']['file']], message.checker) return diag
def use_context_free_hashes(path): """ Override issue hash in the given file by using context free hashes. """ try: plist = plistlib.readPlist(path) files = plist['files'] for diag in plist['diagnostics']: file_path = files[diag['location']['file']] report_hash = generate_report_hash(diag['path'], file_path, get_checker_name(diag)) diag['issue_hash_content_of_line_in_context'] = report_hash if plist['diagnostics']: plistlib.writePlist(plist, path) except (ExpatError, TypeError, AttributeError) as err: LOG.warning('Failed to process plist file: %s wrong file format?', path) LOG.warning(err) except IndexError as iex: LOG.warning('Indexing error during processing plist file %s', path) LOG.warning(type(iex)) LOG.warning(repr(iex)) _, _, exc_traceback = sys.exc_info() traceback.print_tb(exc_traceback, limit=1, file=sys.stdout) except Exception as ex: LOG.warning('Error during processing reports from the plist file: %s', path) traceback.print_exc() LOG.warning(type(ex)) LOG.warning(ex)
def get_report_hash(diagnostic, files): """ Check if checker name is available in the report. Checker hash was not available in older clang versions before 3.8. """ report_hash = diagnostic.get('issue_hash_content_of_line_in_context') if not report_hash: # Generate hash value if it is missing from the report. report_hash = generate_report_hash(diagnostic['path'], files, get_checker_name(diagnostic)) return report_hash