22

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.

you are viewing a single comment's thread
view the rest of the comments
[-] qwop@programming.dev 2 points 1 year ago

From a quick look at the code it looks like it uses regex to extract any name assignments and compares that to usages. This approach seems very limited as it has no understanding of context (e.g. the same name used in multiple places, or special methods like __add__ on classes that aren't called manually).

I'd be interested to know what false positives in vulture this solves. The main false positives I've found with vulture are:

  • Names that are publicly exposed in a library but not actually used
  • Methods in classes that are called by an external parent class defined in some external module.
  • Special cases (for example unittest functions, which aren't called manually, or fastapi route decorator functions)

I don't think this project would solve any of those cases (and in some cases I think vulture has special casing to handle things better).

[-] niekas@programming.dev 2 points 1 year ago* (last edited 1 year ago)

Yes, you are right ๐Ÿ‘ Thanks for pointing this out. And yes, my package is only a subset of vulture functionality.

this post was submitted on 24 Jun 2023
22 points (95.8% liked)

Python

6187 readers
48 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

๐Ÿ“… Events

October 2023

November 2023

PastJuly 2023

August 2023

September 2023

๐Ÿ Python project:
๐Ÿ’“ Python Community:
โœจ Python Ecosystem:
๐ŸŒŒ Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS