1- import csv
2- from io import StringIO
1+ import json
32from SublimeLinter .lint import LintMatch , ComposerLinter
43
54
65class 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