-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsblint2codeclimate.py
executable file
·47 lines (37 loc) · 1.17 KB
/
sblint2codeclimate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import json
severity_map = {"error": "blocker", "warning": "major"}
def severity(category_name):
return next(iter([v for k, v in severity_map.items()
if k in category_name]), "info")
warnings = []
for line in sys.stdin:
try:
location, category, *text = line.split(" ")
filename, line, column, _ = location.split(":")
category = category[:-1]
text = " ".join(text)[:-1]
line = int(line)
column = int(column)
warning = {
"engine_name": "sblint",
"type": "issue",
"check_name": "sblint",
"categories": ["Style"],
"description": text,
"severity": severity(category),
"location": {
"path": filename,
"positions": {
"begin": {"line": line, "column": column},
"end": {"line": line, "column": column + 1},
},
},
}
warnings.append(warning)
except:
continue
with open("gl-code-quality-report.json", "w") as f:
f.write(json.dumps(warnings))