Skip to content

Commit 36e9dee

Browse files
committed
use the json report to circumvent escaped strings
1 parent 4a9203c commit 36e9dee

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

linter.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import csv
2-
from io import StringIO
1+
import json
32
from SublimeLinter.lint import LintMatch, ComposerLinter
43

54

65
class Phpcs(ComposerLinter):
7-
cmd = ('phpcs', '--report=csv', '${args}', '-')
6+
cmd = ('phpcs', '--report=json', '${args}', '-')
87
defaults = {
98
'selector': 'embedding.php, source.php - text.blade',
109
# we want auto-substitution of the filename,
@@ -13,11 +12,14 @@ class Phpcs(ComposerLinter):
1312
}
1413

1514
def find_errors(self, output):
16-
for match in csv.DictReader(StringIO(output)):
17-
yield LintMatch(
18-
line=int(match.get('Line', 1)) - 1,
19-
col=int(match.get('Column', 1)) - 1,
20-
error_type=match.get('Type', 'warning'),
21-
code=match.get('Source', ''),
22-
message=match.get('Message', ''),
23-
)
15+
data = json.loads(output)
16+
for file_path, file_data in data["files"].items():
17+
for error in file_data['messages']:
18+
yield LintMatch(
19+
filename=file_path,
20+
line=error['line'] - 1,
21+
col=error['column'] - 1,
22+
error_type=error['type'].lower(),
23+
code=error['source'],
24+
message=error['message'],
25+
)

0 commit comments

Comments
 (0)