|
6 | 6 |
|
7 | 7 | def test_base_metric():
|
8 | 8 | raise NotImplementedError
|
9 |
| - |
10 |
| - |
11 |
| -def run_pylint(): |
12 |
| - # Run pylint command and parse json |
13 |
| - pylint_out = subprocess.run(['pylint', '--output-format=json', |
14 |
| - "--init-hook=\"import sys; sys.path.append('scripts/')\"", "scripts/*"], stdout=subprocess.PIPE, check=False) |
15 |
| - |
16 |
| - pylint_list = json.loads(pylint_out.stdout) |
17 |
| - |
18 |
| - # Parse pylint format into GitHub Checks Annotation format |
19 |
| - for item in pylint_list: |
20 |
| - # Rename error type to annotation_level |
21 |
| - item['annotation_level'] = item.pop('type') |
22 |
| - |
23 |
| - # translate pylint terms to github terms |
24 |
| - if item['annotation_level'] == "convention": |
25 |
| - item['annotation_level'] = 'notice' |
26 |
| - elif item['annotation_level'] == "refactor": |
27 |
| - item['annotation_level'] = 'warning' |
28 |
| - |
29 |
| - # if end fields are empty, make them the same as the start |
30 |
| - item['end_line'] = item.pop('endLine') |
31 |
| - if item['end_line'] is None: |
32 |
| - item['end_line'] = item['line'] |
33 |
| - |
34 |
| - item['start_line'] = item.pop('line') |
35 |
| - item['start_column'] = item.pop('column') |
36 |
| - item['end_column'] = item.pop('endColumn') |
37 |
| - if item['end_column'] is None: |
38 |
| - item['end_column'] = item['start_column'] |
39 |
| - item['title'] = item.pop('symbol') |
40 |
| - |
41 |
| - # Don't include columns if annotation spans multiple lines |
42 |
| - if item['start_line'] != item['end_line']: |
43 |
| - item.pop('start_column') |
44 |
| - item.pop('end_column') |
45 |
| - item.pop('module') |
46 |
| - item.pop('obj') |
47 |
| - item.pop('message-id') |
48 |
| - |
49 |
| - to_return = pylint_list[:50]#json.dumps(pylint_list, indent=2) |
50 |
| - #Print max of 50 terms since thats the max for GitHub |
51 |
| - print(json.dumps(to_return, indent=2)) |
0 commit comments