buildtools
buildtools copied to clipboard
Add warning for undefined variables
The code:
print(foo)
could generate a warning that foo
is undefined. It's useful in IDEs to get the information quickly (before even running the code).
The reason the warning doesn't exist is that buildifier doesn't know which global variables are available in which types of files. Is there an up-to-date list of existing globals for each type (.bzl/BUILD/WORKSPACE)?
We can get this information. See for example cl/245895979 inside Google and the ApiExporter. We can open-source that.
This is would be very useful for starlark (.bzl
) files for sure. I'm doing some refactoring, and the "unused variable" warnings are very useful, but an undefined variable check would be even more useful.