|
1 | | -from SublimeLinter.lint import ComposerLinter |
| 1 | +import csv |
| 2 | +from io import StringIO |
| 3 | +from SublimeLinter.lint import LintMatch, ComposerLinter |
2 | 4 |
|
3 | 5 |
|
4 | 6 | 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}', '-') |
7 | 8 | defaults = { |
8 | 9 | 'selector': 'embedding.php, source.php - text.blade', |
9 | 10 | # we want auto-substitution of the filename, |
10 | 11 | # but `cmd` does not support that yet |
11 | 12 | '--stdin-path=': '${file}' |
12 | 13 | } |
| 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