Skip to content

Commit 7b01b8d

Browse files
committed
Refactor format method for readability
1 parent 68ce762 commit 7b01b8d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

linter.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,15 @@ def run(self, cmd, code):
4848
def format(self, output):
4949
"""Formats json output to text <file>:<line>:<error>:<message>\n"""
5050

51-
json = json.loads(output)
52-
filename = json['files'][0]['file']
51+
json_output = json.loads(output)
5352
formatted_lines = []
5453

55-
for issue in json['files'][0]['issues']:
56-
message = issue['description'].split('.')[0]
57-
formatted_lines.append(''.join([filename, ':', issue['line'], ':', issue['category'], ':', message, "\n"]))
58-
return ''.join(formatted_lines)
54+
for issue in json_output['files'][0]['issues']:
55+
file = json_output['files'][0]['file']
56+
line = issue['line']
57+
error = issue['category']
58+
message = issue['description']
59+
60+
formatted_lines.append(''.join([file, ':', line, ':', error, ':', message, "\n"]))
5961

62+
return ''.join(formatted_lines)

0 commit comments

Comments
 (0)