PyCQA / flake8

flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.
https://flake8.pycqa.org
Other
3.41k stars 306 forks source link

badge generated from flake8 statistics #1334

Closed smarie closed 3 years ago

smarie commented 3 years ago

Hi there and thanks for this great lib !

This is not an issue, rather information: I have created a library to generate a set of badges for pytest, coverage and flake8. I currently use the output of flake8 --statistics to generate the badge without relying too much on any flake8 internals. The only exception is severity levels : they are obtained from flake8-html internal API so that they match the ones in the HTML report.

If you have any suggestion, comment, etc. feel free to open issues on the project page !

https://smarie.github.io/python-genbadge/

(you can now close this ticket once read :) )

smarie commented 3 years ago

Thanks @asottile I would have hoped for at least a tiny bit of reaction :)

Anyway just one thing that bothers me, maybe you'll have a suggestion: for the other tools (pytest, coverage) there is some kind of standard (junit.xml, coverage.xml) for reporting the statistics, and I rely on this so that I can parse reports coming from other frameworks (junit, cobertura, etc.). In the case of flake8 I could not find any and ended up using the --statistics output. Is there a better / more standard way ?

Also, since flake8 itself does not define the 3 severity levels used in flake8-html, I end up having a dependency to the internal API of flake8-html, for the method converting an error code to a severity level. See this ticket. Here I feel that it would be more consistent to have the severity level "standardized" and output to the statistics file. This would as a consequence, remove the dependency between genbadge and the flake8 libraries. Any thought on this ?

Thanks again for your time !

asottile commented 3 years ago

flake8-json will give you better machine readable output, or you can use --format to control the output (such as parseable tab-separated output)

there's no such thing as severity, that's something flake8-html invented and I would not use it. the individual code names do not infer how severe of an error they are (E / F / W do not stand for error / failure / warning for example). I would not recommend you proliferate this concept from flake8-html

admittedly I don't see the point of a flake8 badge -- any linter failures should be either solved or intentionally silenced so it should always be 0

smarie commented 3 years ago

Thanks @asottile for the answer and links !

admittedly I don't see the point of a flake8 badge -- any linter failures should be either solved or intentionally silenced so it should always be 0

Well after 15 years of industrial and open source software development I have to say that even if this is true in theory, in practice it is very rarely the case: mature and high-quality projects are very rare out there ;) . So I prefer to motivate reluctant developers to use flake8 first (a new badge, yay!), and then to transparently expose the remaining failures rather than spending time to ignore them or fix them (even if they'll do it eventually when their project matures). You can see this as a way to drive people towards quality.

Thanks again for your time ! I'll link your suggestion to a new issue in genbadge now

asottile commented 3 years ago

I have similar years of experience and have not worked on a project where flake8 src tests produces a single message.

smarie commented 3 years ago

wow ! I'm impressed. I have seen projects not using flake8 at all, or using it but ignoring it, or... I mean, just browse for a random project on pypi... Most of my own open source libs do not use flake8 at all and, well, they are used at least by some people ;)

Anyway, I'm not saying that gamification is the answer to everything of course, but at least if it can drive some developers to code quality then that's already a win. Thanks again !

asottile commented 3 years ago

going from the top 10 packages on pypi

anyway, this has run its course, good day