buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

buildifier: Catch broad glob patterns

Open UebelAndre opened this issue 3 years ago • 0 comments

Would it be possible for buildifier to detect and warn about the use of open ended glob patterns?

filegroup(
    name = "sources",
    srcs = glob(["src/*"]),
)

I'm finding this pattern in quite a few places and it ends up introducing cache invalidation as local developers unknowingly have temp files rendered there by their IDE or some other process in their workflow, thus causing Bazel to rebuild targets when it shouldn't.

Instead, I'd want developers to add patterns similar to the following:

diff --git a/BUILD b/BUILD
index d88dd2b..77b4d51 100644
--- a/BUILD
+++ b/BUILD
@@ -1,4 +1,8 @@
 filegroup(
     name = "sources",
-    srcs = glob(["src/*"]),
+    srcs = glob([
+        "src/*.rs",
+        "src/*.cc",
+        "src/*.h",
+    ]),
 )

UebelAndre avatar Sep 11 '22 21:09 UebelAndre