jendrikseipp / vulture

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

[Feature Request] Warn about empty files #197

Closed dosisod closed 4 years ago

dosisod commented 4 years ago

Consider the .py file below:

"""
def old_code():
    print("delete me!")
"""

It clearly was commented out, and then forgotten about. It probably isn't mean to be there anymore.

Obviously, there are cases where you would want empty python files, for example, __init__.py. In general though, it would be better to tell the user about it.

Open to ideas!

RJ722 commented 4 years ago

Hi @dosisod, thanks for creating this issue.

Although I think your usecase is pretty reasonable, but I think that this feature doesn't fit in the [current] scope of Vulture.

Also, we wouldn't do anything about a commented out piece of code which resides in a file which has other code as well. That behavior could be a little confusing for users.

dosisod commented 4 years ago

It could be commented out code, comments without code, or simply a file with nothing in it. Maybe there could be an option that would enable this behavior, and have it disabled by default.

As long as it does not have any false positives, I don't see any major issues with this addition, though I may be wrong.

jendrikseipp commented 4 years ago

I think the idea is interesting, but it's probably such a rare case that files only contain comments that it's not worth the trouble of maintaining the code for reporting them. Also, even a file with only an unnamed string might serve a legitimate purpose, since we can access the string with __doc__.