Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited tags
Link
Drew
  • 80.9k
  • 10
  • 125
  • 265
Source Link
Clément
  • 4.1k
  • 1
  • 26
  • 41

Can the byte-compiler warn me about unused variables?

I've just finished a pretty significant refactoring; byte-compiler warnings were a great way to quickly find errors, without even running tests.

Still, there's one kind of code smell that the byte-compiler doesn't seem to catch: unused variables. And unfortunately, tests are powerless against that one.

For example, my recent refactoring caused a number of internal defconsts to become useless; but I didn't get warnings. Same for defvars and even a few defuns. All of these were private my-package--blah, so I really don't expect them to be used outside of the package. Even then, "unused definition" warnings would be useful (I'd mark the definitions obsolete, for example).

Is there a way to get warnings about unused definitions? I don't mind false positives too much (using intern and eval could hide uses of a definition from the byte-compiler, for example).