-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline ignoring again #360
Comments
I agree with what @mdevaev is saying, and to add some additional context: my company is using Vulture, and in general it works really well, but the whitelist file is a continuous source of pain. Our The only other alternative to this, IMO, would be a whitelist file which is less specific about the line number of everything. Right now the unused code is specified as `my_variable_name # unused variable (a/b/c/my_module.py:line_number) Even just specifying the module path like |
Thanks for your input! I'll think a bit more about inline comments. But regarding the problem of line numbers in the whitelist file: you can simply remove all line numbers. The comments in that file are ignored by Vulture and only meant for humans. |
I'm using this file without line numbers. There is still the problem of "distributed knowledge" about unused fields. That is, I open a file with a description of structures, and from it it is not obvious to me which fields are used in the project and which are not. I will have to use a code search, or look at the list in vulture. By the way, a similar technique with unused function arguments exists in C. When warnings are enabled, the compiler will complain about unused arguments for functions. Therefore, there are two ways to mark such variables: int foo(int x) {
(void)x; // This is unused
return 0;
}
int bar (__attribute__((unused)) int y) {
return 0;
} While I was writing about this, I thought about the semantics of inline and that it could really be a source of knowledge about the use of fields or variables in code:
If a variable has been marked and it has been started to be used, vulture forces the developer to remove the corresponding label. This is a small self-checking documentation. I find it very useful. |
Sup? |
Sup |
Hello. I'm about #9.
I'm opening a new issue because I want to describe my use case and ask you to reconsider your decision regarding the support of inline comments like
# vulture: ignore
.I am developing software that actively interacts with hardware using binary protocols. I describe individual elements of the protocol using dataclasses, for example:
This class describes the response from the hardware and possible response options. But due to the fact that hardware often has more features than it is processed in software (for example, the payload for the error is not important to us, only the NAK itself is important), the response fields may not be used, or some constants, although defined, will not be used either.
So vulture is triggered on them. I don't want to delete the field definitions because this is actually the protocol documentation in the code, and I don't want to delete unused protocol constants for the same reason. The only way to silence vulture is to have a separate file with a list of fields, or commenting them.
It turns out that I have two places where I describe some things from the protocol: here is the class itself, and here is a separate list of unused things. However, if I start using some field or constant, I often forget to remove it from the vulture list. But the class definition file is a natural place that I often visit. And if I could describe exactly there that these fields are not used, it would be more convenient. My definition would no longer be split into two files. Like this:
I understand your arguments in #9, but I ask you to review this feature because it will greatly simplify my life :)
The text was updated successfully, but these errors were encountered: