jendrikseipp / vulture

Find dead Python code
MIT License
3.38k stars 148 forks source link

Obvious unused functions are not reported with 70% min confidence #261

Closed noorul closed 2 years ago

noorul commented 3 years ago

Reproduction recipe (test.py):

def foo():
    pass

def bar():
    pass

bar()

Vulture output:

% ./ENV/bin/vulture --min-confidence=60 test.py
test.py:1: unused function 'foo' (60% confidence)
% ./ENV/bin/vulture --min-confidence=70 test.py
% 
RJ722 commented 3 years ago

This is how it meant to be -- when the min-confidence flag is supplied, only results with confidence greater than the supplied value are shown.

It'd be nice to know what you expected to happen here?

noorul commented 3 years ago

For the snippet, I was expecting vulture to report this unused function with 100%. Am I missing something?

RJ722 commented 3 years ago

Ah, I see. The confidence value is based on the 'type' of the unused item. For functions/methods, it is always 60%. For unused imports, it's 95%, and so on.

noorul commented 3 years ago

Then I am not sure whether I understood it properly. I set vulture to use a 70% confidence level because lower than that was giving false positive outputs. But this completely filtered out functions and methods.

RJ722 commented 2 years ago

In that case, to deal with false positives, I'd recommend adding a whitelist. You can even run Vulture with the --make-whitelist flag -- this would print all the results in a form directly usable as a whitelist. More info in the README.

noorul commented 2 years ago

I managed to move to a 60% confidence level. I see that --make-whitelist is an option.