jendrikseipp / vulture

Find dead Python code
MIT License
3.41k stars 150 forks source link

More definitive explanation of 'confidence' in README #255

Closed db-baron closed 3 years ago

db-baron commented 3 years ago

It's a little unclear how the confidence percentage estimates for unused code are calculated. Perhaps include a description of the process by which it's determined in the documentation.

RJ722 commented 3 years ago

I agree that knowing how confidence is calculated would help users select the value of min-confidence, well, more confidently.

The confidence level is based on the 'type' of the dead code. The logic is scattered in vulture/core.py in various calls to self._define. (e.g., https://github.com/jendrikseipp/vulture/blob/master/vulture/core.py#L666 -- which detects unreachable code after return/raise/break with 100% confidence).

It would be nice to have a table with all the values in one place. Would you be interested in making a PR @db-baron?

jendrikseipp commented 3 years ago

Thanks for the explanation, @RJ722! I reworded the paragraph about confidence values slightly to make it clearer. In essence, the estimates only depend on the type of code (import, function, class, etc.) and are very rough, heuristic estimates.