Skip to content

Commit 4a9203c

Browse files
committed
use the CSV format
issue: quotes are escaped in the messages
1 parent 6e12dc2 commit 4a9203c

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

linter.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
from SublimeLinter.lint import ComposerLinter
1+
import csv
2+
from io import StringIO
3+
from SublimeLinter.lint import LintMatch, ComposerLinter
24

35

46
class Phpcs(ComposerLinter):
5-
cmd = ('phpcs', '--report=checkstyle', '${args}', '-')
6-
regex = r'^\s*<error line="(?P<line>\d+)" column="(?P<col>\d+)" severity="(?:(?P<error>error)|(?P<warning>warning))" message="(?P<message>[^"]+)" source="(?P<code>[^"]+)"' # noqa: E501
7+
cmd = ('phpcs', '--report=csv', '${args}', '-')
78
defaults = {
89
'selector': 'embedding.php, source.php - text.blade',
910
# we want auto-substitution of the filename,
1011
# but `cmd` does not support that yet
1112
'--stdin-path=': '${file}'
1213
}
14+
15+
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+
)

0 commit comments

Comments
 (0)