Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

badge generated from flake8 statistics #1334

Closed
smarie opened this issue May 17, 2021 · 6 comments
Closed

badge generated from flake8 statistics #1334

smarie opened this issue May 17, 2021 · 6 comments

Comments

@smarie
Copy link

smarie commented May 17, 2021

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
Copy link
Author

smarie commented May 18, 2021

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
Copy link
Member

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
Copy link
Author

smarie commented May 18, 2021

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
Copy link
Member

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

@smarie
Copy link
Author

smarie commented May 18, 2021

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
Copy link
Member

going from the top 10 packages on pypi

anyway, this has run its course, good day

@PyCQA PyCQA locked as resolved and limited conversation to collaborators May 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants