SublimeLinter / SublimeLinter-rubocop

SublimeLinter 3 plugin for Ruby, using rubocop.
MIT License
159 stars 40 forks source link

Fix regex #76

Closed capripot closed 3 years ago

capripot commented 3 years ago

I noticed that the message given by Sublime Linter with Rubocop in the popup was not as great as it could be:

old

This PR fixes it:

new

The new regexp is the following: ^.+?:(?P<line>\d+):(?P<col>\d+): (:?(?P<warning>[RCW])|(?P<error>[EF])): (?P<fixable>\[Correctable\] )?((?P<code>[A-Za-z]+/[A-Za-z]+): )?(?P<message>.+)$

I used this Pythex%3A%20(%3FP%3Cfixable%3E%5C%5BCorrectable%5C%5D%20)%3F((%3FP%3Ccode%3E%5BA-Za-z%5D%2B%2F%5BA-Za-z%5D%2B)%3A%20)%3F(%3FP%3Cmessage%3E.%2B)%24&test_string=file.rb%3A127%3A58%3A%20C%3A%20%5BCorrectable%5D%20Layout%2FHashAlignment%3A%20Align%20the%20keys%20and%20values%20of%20a%20hash%20literal%20if%20they%20span%20more%20than%20one%20line.%0Afile.rb%3A76%3A1%3A%20E%3A%20Lint%2FSyntax%3A%20unexpected%20token%20%24end%20(Using%20Ruby%202.7%20parser%3B%20configure%20using%20%60TargetRubyVersion%60%20parameter%2C%20under%20%60AllCops%60)%0Afile.rb%3A128%3A58%3A%20C%3A%20%5BCorrectable%5D%20Align%20the%20keys%20and%20values%20of%20a%20hash%20literal%20if%20they%20span%20more%20than%20one%20line.&ignorecase=0&multiline=1&dotall=0&verbose=0) to help building the regular expression.

Now the Cop Name is used as code (instead of severity). Severity is already indicated with the type of icon (warning or error). If somehow the Cop Name is not available, it will still work and behave as the former RegExp (see example 3 on Pythex).

Note: It will also help getting quick action released for Rubocop, as the new RegExp properly label code.

kaste commented 3 years ago

I like this a lot. I think I just take it and hope the display-cop-name is an old enough switch.

Do you have the code actions working. At least the icon is already present in the screenshots.

capripot commented 3 years ago

Looks like it's been around for over 7 years now. Can one override it with the cmd options in Settings?

Yes I got the code actions working, so helpful! I'll open an other PR for it.

kaste commented 3 years ago

7 years is good enough, I think. Thanks for looking that up.