bazel-contrib / bazel-contrib/buildtools

[buildifier] false positive on canonical-repository linter

Open
#1,391 4 comments 0 reactions 0 assignees View on GitHub
bug P2
Dominant language
Go
Stars
1.2k
Forks
471
Avg merge
2d 22h
Merged PRs (30d)
13

Description

`canonical-repository` is flagging a false positive, strings with string substitutions containing `@@` as causing a flag.

Extract of code causing the flag:

```
...
ctx.actions.expand_template(
template = ctx.file._runner,
output = out_file,
substitutions = {
"@@GOFMT_BIN@@": shell.quote(gofmt_path),
"@@GOROOT@@": shell.quote(sdk.root_file.dirname),
},
is_executable = True,
)
transitive_depsets = [
depset([sdk.go]),
]
...
```

Buildifier output on master:

```
$ buildifier -lint warn -r .
tools/linters/golang/defs.bzl:22: canonical-repository: String contains "@@" which indicates a canonical repository name reference that should be avoided. (https://github.com/bazelbuild/buildtools/blob/main/WARNINGS.md#canonical-repository)
tools/linters/golang/defs.bzl:23: canonical-repository: String contains "@@" which indicates a canonical repository name reference that should be avoided. (https://github.com/bazelbuild/buildtools/blob/main/WARNINGS.md#canonical-repository)
```

Buildifier output on `v8.2.1`

```
$ buildifier -lint warn -r .
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the report with buildifier -lint warn -r . and inspect tools/linters/golang/defs.bzl around lines 22–23. Determine how the canonical-repository linter handles strings containing @@; done means these substitution strings no longer produce false positives while genuine canonical repository references remain warned.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.