Skip to content

Commit 8765208

Browse files
committed
Add JSON output decoder and preliminary linter report
1 parent a11a4f7 commit 8765208

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

linter.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,27 @@ def tmpdir(self, cmd, dir, files, filename, code):
6060
except PermissionError:
6161
print("golangcilint permission error on `{}`".format(dir))
6262
return ""
63+
64+
def execute(self, cmd):
65+
lines = []
66+
output = self.communicate(cmd)
67+
report = json.loads(output)
68+
currnt = os.path.basename(self.filename)
69+
70+
"""format issues into formal pattern"""
71+
for issue in report["Issues"]:
72+
name = issue["Pos"]["Filename"]
73+
mark = name.rfind("/")
74+
mark = 0 if mark == -1 else mark+1
75+
issue["Pos"]["Shortname"] = name[mark:]
76+
lines.append(
77+
"{}:{}:{}:{}:{}".format(
78+
issue["Pos"]["Shortname"],
79+
issue["Pos"]["Line"],
80+
issue["Pos"]["Column"],
81+
issue["Level"],
82+
issue["Text"]
83+
)
84+
)
85+
86+
return "\n".join(lines)

0 commit comments

Comments
 (0)