archweb
archweb copied to clipboard
Add vulture to CI
Add vulture (dead code detector to CI)
Hello !
I run the following command :
vulture --exclude=*/migrations/*.py --min-confidence 65 devel/**/*.py main/**/*.py mirrors/**/*.py news/**/*.py packages/**/*.py planet/**/*.py public/**/*.py releng/**/*.py todolists/**/*.py visualize/**/*.py
and it gives me the following results :
archweb/devel/management/commands/reporead.py:215: unused variable 'package_sigs' (100% confidence)
archweb/mirrors/admin.py:77: unused variable 'change' (100% confidence)
archweb/mirrors/fields.py:46: unused variable 'expression' (100% confidence)
archweb/packages/tests/test_flag_packages.py:37: unused variable 'denylist' (100% confidence)
archweb/packages/tests/test_search.py:1: unused variable 'db' (100% confidence)
archweb/packages/tests/test_views.py:1: unused variable 'db' (100% confidence)
archweb/packages/tests/test_views.py:6: unused variable 'db' (100% confidence)
archweb/packages/tests/test_views.py:63: unused variable 'db' (100% confidence)
archweb/planet/tests/test_command.py:17: unused variable 'db' (100% confidence)
archweb/planet/tests/test_views.py:9: unused variable 'db' (100% confidence)
archweb/planet/tests/test_views.py:16: unused variable 'db' (100% confidence)
archweb/planet/tests/test_views.py:29: unused variable 'db' (100% confidence)
archweb/releng/tests/conftest.py:15: unused variable 'db' (100% confidence)
archweb/releng/tests/test_views.py:18: unused variable 'db' (100% confidence)
archweb/releng/tests/test_views.py:26: unused variable 'db' (100% confidence)
archweb/releng/tests/test_views.py:31: unused variable 'db' (100% confidence)
If I don't set the --min-confidence
attribute, I get a lot of false positive (models attributes, Meta
class, etc) so I raise it just a little bit to have more accurate results, but even there, almost all results are false positive since the unused variable 'db'
is always in the tests functions signature.
Do you think it's worth it to find a way to "whitelist" the warnings related to the test files and implement this in a pipeline or we should simply fix the three unused variables and leave it like that?
Hey, I was thinking maybe using vulture in a pre-commit hook would be better than directly adding it to the CI pipeline.
Hello !
I run the following command :
vulture --exclude=*/migrations/*.py --min-confidence 65 devel/**/*.py main/**/*.py mirrors/**/*.py news/**/*.py packages/**/*.py planet/**/*.py public/**/*.py releng/**/*.py todolists/**/*.py visualize/**/*.py
and it gives me the following results :
archweb/devel/management/commands/reporead.py:215: unused variable 'package_sigs' (100% confidence) archweb/mirrors/admin.py:77: unused variable 'change' (100% confidence) archweb/mirrors/fields.py:46: unused variable 'expression' (100% confidence) archweb/packages/tests/test_flag_packages.py:37: unused variable 'denylist' (100% confidence) archweb/packages/tests/test_search.py:1: unused variable 'db' (100% confidence) archweb/packages/tests/test_views.py:1: unused variable 'db' (100% confidence) archweb/packages/tests/test_views.py:6: unused variable 'db' (100% confidence) archweb/packages/tests/test_views.py:63: unused variable 'db' (100% confidence) archweb/planet/tests/test_command.py:17: unused variable 'db' (100% confidence) archweb/planet/tests/test_views.py:9: unused variable 'db' (100% confidence) archweb/planet/tests/test_views.py:16: unused variable 'db' (100% confidence) archweb/planet/tests/test_views.py:29: unused variable 'db' (100% confidence) archweb/releng/tests/conftest.py:15: unused variable 'db' (100% confidence) archweb/releng/tests/test_views.py:18: unused variable 'db' (100% confidence) archweb/releng/tests/test_views.py:26: unused variable 'db' (100% confidence) archweb/releng/tests/test_views.py:31: unused variable 'db' (100% confidence)
If I don't set the
--min-confidence
attribute, I get a lot of false positive (models attributes,Meta
class, etc) so I raise it just a little bit to have more accurate results, but even there, almost all results are false positive since theunused variable 'db'
is always in the tests functions signature.Do you think it's worth it to find a way to "whitelist" the warnings related to the test files and implement this in a pipeline or we should simply fix the three unused variables and leave it like that?
Yes, we should whitelist python fixtures as they are detected as false positives
@MashyBasker if you want to go forward and make a PR to run it as a pre-commit
hook, go ahead. It has been two years since I comment this issue, and I've change workstation since then, so the work I had for this issue is gone.
If you don't have time, I'll try to get at it when I got some free time ! :)
Thanks! I'll work on creating the pre-commit hook PR.
Thanks! I'll work on creating the pre-commit hook PR.
pre-commit hook is the not super interesting. Getting the code to run fine with vulture be a good start.
Okay, I'll work on it. @jelly