Showing
2 changed files
with
48 additions
and
2 deletions
@@ -54,7 +54,7 @@ publish-printing: format clean | @@ -54,7 +54,7 @@ publish-printing: format clean | ||
54 | touch .pana | 54 | touch .pana |
55 | 55 | ||
56 | analyze: .pana | 56 | analyze: .pana |
57 | - pana --no-warning --source path pdf | ||
58 | - pana --no-warning --source path printing | 57 | + @pana --no-warning --source path pdf 2> /dev/null | python pana_report.py |
58 | + @pana --no-warning --source path printing 2> /dev/null | python pana_report.py | ||
59 | 59 | ||
60 | .PHONY: test format format-dart format-clang clean publish-pdf publish-printing analyze | 60 | .PHONY: test format format-dart format-clang clean publish-pdf publish-printing analyze |
pana_report.py
0 → 100644
1 | +from __future__ import print_function | ||
2 | +import sys | ||
3 | +import json | ||
4 | +import re | ||
5 | + | ||
6 | + | ||
7 | +def parse_suggestions(data): | ||
8 | + for item in data: | ||
9 | + print(' -', item['description'].replace( | ||
10 | + '\n\n', | ||
11 | + '\n').replace('\n', '\n ')) | ||
12 | + | ||
13 | + | ||
14 | +def parse_key(data): | ||
15 | + for key, val in data.iteritems(): | ||
16 | + if val is False: | ||
17 | + continue | ||
18 | + if val == 0: | ||
19 | + continue | ||
20 | + if key == 'strongModeEnabled' and val is True: | ||
21 | + continue | ||
22 | + label = re.sub(r"([a-z])([A-Z])", r"\g<1> \g<2>", key).capitalize() | ||
23 | + if key == 'suggestions': | ||
24 | + print(' - {key}:'.format(key=label)) | ||
25 | + parse_suggestions(val) | ||
26 | + continue | ||
27 | + print(' - {key}: {val}'.format(key=label, val=val)) | ||
28 | + | ||
29 | + | ||
30 | +def main(): | ||
31 | + json_data = sys.stdin.read() | ||
32 | + data = json.loads(json_data) | ||
33 | + | ||
34 | + data['problems'] = data['health']['analyzeProcessFailed'] or data['health'][ | ||
35 | + 'formatProcessFailed'] or data['health']['resolveProcessFailed'] | ||
36 | + data['healthErrors'] = data['health']['analyzerErrorCount'] | ||
37 | + data['healthWarnings'] = data['health']['analyzerWarningCount'] | ||
38 | + data['healthHint'] = data['health']['analyzerHintCount'] | ||
39 | + data['healthConflict'] = data['health']['platformConflictCount'] | ||
40 | + | ||
41 | + print('Package {packageName} version {packageVersion}'.format(**data)) | ||
42 | + parse_key(data['health']) | ||
43 | + parse_key(data['maintenance']) | ||
44 | + | ||
45 | +if __name__ == "__main__": | ||
46 | + main() |
-
Please register or login to post a comment