buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

Add warning for undefined variables

Open laurentlb opened this issue 5 years ago • 3 comments

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).

laurentlb avatar Apr 29 '19 21:04 laurentlb

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)?

vladmos avatar Apr 30 '19 17:04 vladmos

We can get this information. See for example cl/245895979 inside Google and the ApiExporter. We can open-source that.

laurentlb avatar Apr 30 '19 17:04 laurentlb

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.

kghose avatar Sep 06 '22 17:09 kghose