diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:01 +0000 |
commit | 486754660bb926339aefcf012a3f848592babb8b (patch) | |
tree | ecdbc446c9876f4f120f701c243373cd3cb43db3 /tools/scan-build-py/libscanbuild/report.py | |
parent | 55e6d896ad333f07bb3b1ba487df214fc268a4ab (diff) |
Notes
Diffstat (limited to 'tools/scan-build-py/libscanbuild/report.py')
-rw-r--r-- | tools/scan-build-py/libscanbuild/report.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/scan-build-py/libscanbuild/report.py b/tools/scan-build-py/libscanbuild/report.py index 54b9695d927fc..b3753c1d9d4e9 100644 --- a/tools/scan-build-py/libscanbuild/report.py +++ b/tools/scan-build-py/libscanbuild/report.py @@ -13,7 +13,6 @@ import os import os.path import sys import shutil -import itertools import plistlib import glob import json @@ -255,24 +254,29 @@ def read_crashes(output_dir): def read_bugs(output_dir, html): + # type: (str, bool) -> Generator[Dict[str, Any], None, None] """ Generate a unique sequence of bugs from given output directory. Duplicates can be in a project if the same module was compiled multiple times with different compiler options. These would be better to show in the final report (cover) only once. """ - parser = parse_bug_html if html else parse_bug_plist - pattern = '*.html' if html else '*.plist' + def empty(file_name): + return os.stat(file_name).st_size == 0 duplicate = duplicate_check( lambda bug: '{bug_line}.{bug_path_length}:{bug_file}'.format(**bug)) - bugs = itertools.chain.from_iterable( - # parser creates a bug generator not the bug itself - parser(filename) - for filename in glob.iglob(os.path.join(output_dir, pattern))) - - return (bug for bug in bugs if not duplicate(bug)) + # get the right parser for the job. + parser = parse_bug_html if html else parse_bug_plist + # get the input files, which are not empty. + pattern = os.path.join(output_dir, '*.html' if html else '*.plist') + bug_files = (file for file in glob.iglob(pattern) if not empty(file)) + + for bug_file in bug_files: + for bug in parser(bug_file): + if not duplicate(bug): + yield bug def parse_bug_plist(filename): |