| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
They have various formatters. You could use csv. Python ships a csv reader. import csv from io import StringIO csv_text = '''File,Line,Column,Type,Message,Source,Severity,Fixable "/path/to/code/classA.php",2,1,error,"Missing file doc comment",PEAR.Commenting.FileComment.Missing,5,0 "/path/to/code/classA.php",4,12,error,"TRUE, FALSE and NULL must be lowercase; expected \"false\" but found \"FALSE\"",Generic.PHP.LowerCaseConstant.Found,5,1 "/path/to/code/classA.php",6,2,error,"Line indented incorrectly; expected at least 4 spaces, found 1",PEAR.WhiteSpace.ScopeIndent.Incorrect,5,1 "/path/to/code/classA.php",9,1,error,"Missing function doc comment",PEAR.Commenting.FunctionComment.Missing,5,0 "/path/to/code/classA.php",11,5,warning,"Inline control structures are discouraged",Generic.ControlStructures.InlineControlStructure.Discouraged,5,1''' # Read CSV from string csv_reader = csv.DictReader(StringIO(csv_text)) You would implement def find_errors(self, output): for match in csv_reader:
yield LintMatch(
match=match,
filename=match['File'],
line=int(match['Line']) - 1, # apply line_col_base manually ??
col=_try(lambda: int(match['Column']) - 1), ??
error_type=match['Type'],
code=match.get('Source', ''),
message=match['Message'],
)
Does that make sense at all? But if you find xml easytrivial to parse then throw the regex on it. |
Sorry, something went wrong.
Ha, well, "parse" meant loosely here. Of course using a regex here is loaded with assumptions (each error on a line, attributes in a certain order). With these kinds of things, that usually works well though. I'll look into using the json output, that's more my speed than csv. Might even try to look into the other open issues 🤞🏻 |
Sorry, something went wrong.
|
csv is faster 😏 csv_reader = csv.DictReader(StringIO(output)) |
Sorry, something went wrong.
get access to the error code, missing from the emacs output also make the quick action work
issue: quotes are escaped in the messages
|
Might be faster, but then I need to do more work to get rid of various escapes in strings (\" etc). Perhaps the CSV lib can do that for me, but couldn't find that info. The JSON lib takes care of that for me, so that ends up being a cleaner implementation IMO. |
Sorry, something went wrong.
|
Ah, sorry, quotechar and delimiter would have been just options/kwargs to the DictReader. Is this ready. Looks like it is. |
Sorry, something went wrong.
Sorry, something went wrong.
|
Hm. Actually, what is the change here? The error code was in regex before. You added that in #51 |
Sorry, something went wrong.
Sorry, something went wrong.
|
Have you -s on or off? |
Sorry, something went wrong.
|
Oh... guess I didn't read the readme. Granted, it's been 5 years 😅 And nobody reads readmes 😉 . Why would you have to turn on? Also it makes the quick action not work at all (it will insert something like ignore error which doesn't do anything).
You know, that's a fair point, but without the error codes it leaves the plugin in a half broken state IMO. Maybe aesthetically less pleasing, but error codes are useful even if they're ugly and long, and capturing "error" or "warning" instead is just wrong. Huh, ok... so I guess this PR disagrees with me from 5 years ago. I like to think I learned and improved in the mean time 😉 If you want to keep it as is that's fine, I'll fork it. |
Sorry, something went wrong.
|
Let's take it. Less options. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Example output in this mode:
This is trivial to parse, and also has the "source", which we need to make the quick action actually work.