buildtools
buildtools copied to clipboard
buildifier: docstrings for global variables should not be considered
Buildifier should allow docstrings on global variables. It currently does not and by applying something like the following diff to rules_rust
diff --git a/version.bzl b/version.bzl
index 7e40f459..fdee7b85 100644
--- a/version.bzl
+++ b/version.bzl
@@ -1,3 +1,4 @@
"""The version of rules_rust."""
VERSION = "0.9.0"
+"""The current version of rules_rust"""
The following warning is shown:
rust/defs.bzl:68: no-effect: Expression result is not used. Docstrings should be the first statements of a file or a function (they may follow comment lines). (https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#no-effect)
I'd recommend that you use a comment:
# The current version of rules_rust
VERSION = "0.9.0"
Buildifier has special handling for comments, they are attached to a piece of code. So if a refactoring moves or deletes the variable, it will also move or delete the attached comment.
I know that works but I’d consider this a feature request. I want to have docstrings for globals and right now buildifier is a big advocate against that due to the existing lint. I think the lint is wrong and it would be wonderful to support this and implement into IDE extensions