You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
buildifier should include a warning that checks for the use of recursive glob patterns (glob(["**/*.java"])) in Bazel build files, as recommended in the Bazel build style guide.
Motivation
We have encountered a problem where some source files were not being found due to the use of a recursive glob pattern in our Bazel build files. The issue was particularly confusing for our developers, as the missing files were difficult to diagnose due to the nested build files and the combination of local and sandbox builds.
The Bazel build style guide recommends against using recursive glob patterns, as they can lead to unintended consequences and performance issues. Specifically, the guide states1:
Recursive globs make BUILD files difficult to reason about because they skip subdirectories containing BUILD files.
Recursive globs are generally less efficient than having a BUILD file per directory with a dependency graph defined between them as this enables better remote caching and parallelism.
It is good practice to author a BUILD file in each directory and define a dependency graph between them.
Proposed Change
buildifier should include a new warning recursiveGlobPatternWarning that checks for the use of recursive glob patterns in Bazel build files. The warning should suggest using explicit lists of files or non-recursive globs instead.
Implementation Reference
The implementation for this warning would likely be similar to constantGlobPatternWarning. However, as I am not an expert in the buildifier project or Go, I would love to find someone with more experience in this area to implement the proposed change. 🤞
Summary
buildifier should include a warning that checks for the use of recursive glob patterns (
glob(["**/*.java"])
) in Bazel build files, as recommended in the Bazel build style guide.Motivation
We have encountered a problem where some source files were not being found due to the use of a recursive glob pattern in our Bazel build files. The issue was particularly confusing for our developers, as the missing files were difficult to diagnose due to the nested build files and the combination of local and sandbox builds.
The Bazel build style guide recommends against using recursive glob patterns, as they can lead to unintended consequences and performance issues. Specifically, the guide states1:
Proposed Change
buildifier should include a new warning
recursiveGlobPatternWarning
that checks for the use of recursive glob patterns in Bazel build files. The warning should suggest using explicit lists of files or non-recursive globs instead.Implementation Reference
The implementation for this warning would likely be similar to constantGlobPatternWarning. However, as I am not an expert in the buildifier project or Go, I would love to find someone with more experience in this area to implement the proposed change. 🤞
Footnotes
https://bazel.build/build/style-guide#recursive ↩
The text was updated successfully, but these errors were encountered: