That's truly clever! Good old sed to the rescue.

Many thanks,
Johan
On Friday, 8 October 2021 at 10:24:20 UTC+2 jj wrote:

> Hi Johan,
>
> You could try this:
>
> flake8 foobar.py | sed -E 's/([FEW][0-9]+)/\1 \1:/g' | bbresults 
> --pattern flake8
>
> Piping through sed will repeat the 'type' twice so it appears at the start 
> of the message.
>
> HTH
>
> Jean Jourdain
> On Thursday, October 7, 2021 at 10:14:54 PM UTC+2 Johan Larsson wrote:
>
>> I have just discovered the utility bbresults thanks to Patrick at Bare 
>> Bones. As the manual page suggests, using it as processor of flake8 output 
>> is really useful. One little drawback of the current built-in parser is 
>> that the actual ID of an error or warning is consumed by the built-in 
>> flake8 regular expression. So why do I see this as a drawback? Depending on 
>> your coding style, preferences and/or the problem the code is trying to 
>> solve, you may want to prohibit flake8 from pointing out certain errors or 
>> violations.
>>
>> [image: Bild 2021-10-03 kl. 21.19.jpg]
>>
>> So I tried to improve the built-in regular expression as documented in 
>> the man page.
>>
>> Not being an regex expert myself, I failed to include the warning or 
>> error ID in the type group and somehow tack it on later for the msg part… 
>> Here is my go at it, which only slightly improves the situation by 
>> including the numerical part of the ID in the msg.
>>
>> '(?P<file>.+?):(?P<line>\d+):(?P<col>\d+):\s+*(?P<type>[EWF](?=\d+))*
>> (?P<msg>.*)$'
>>
>> [image: Bild 2021-10-03 kl. 21.32.jpg]
>>
>> It’s far from ideal, but at least you know that if a violation is an 
>> Error, you stick an ’E’ in front of the numerical ID to get the complete 
>> code, ’W’ for a warning, and most likely an ’F’ for a note.
>>
>> Another option is of course to fall back to using the default parser in 
>> bbresults, but the resulting output is a bit bleak as all entries are now 
>> notes:
>>
>> [image: Bild 2021-10-03 kl. 21.39.jpg]
>>
>> Anyone out there with a better idea?
>>
>> Best regards,
>> Johan
>>
>>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/d8699a7e-23a9-480e-b77b-e183321875f5n%40googlegroups.com.

Reply via email to