- cross-posted to:
- devops@programming.dev
- cross-posted to:
- devops@programming.dev
Sometimes unused class or function manages to slip into code base. Static code checkers like ruff, flake8 does not have rules for detecting such globally unused code.
I tried using vulture, but it has too many false positives to have it as part of CI/CD pipeline.
I have tried to implement my own, more reliable check for global deadcode detection.
Please let me know what you think about it.
Just coming back around on the count thing, in order to use
wc -l
, you need to ensure that stderr is piped too. Like:deadcode . --exclude=*/tests,conftest.py --ignore-names-in-files=core/settings.py 2>&1 | wc -l
I ran this against a ~8 month old Django project and it turned up 11 unused names, of which 5 were expected and can be whitelisted. Nice!