bazel-contrib / bazel-contrib/buildtools

[buildifier] Bug: Possible false positive with `canonical-repository` on targets starting with `@@//`

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

Description

If you have a target `//foo:bar` in your main repo, and want to refer to it from an external repo, the only way (AFAIK) to do this is `@@//foo:bar`. `canonical-repository` flags this, but I don't think this provides any value, as the intent is to avoid actual fragile strings such as `@@protobuf~5.27.0`. The only thing this could possibly catch in this case is that the `@@` may be redundant.

Coupled with #1391, I think the logic should flag on any string with `@@` and `//` in it, _except_ for any string with `@@//` in it.

Contributor guide

Open the contributing guide

Research direction

Start at buildifier's canonical-repository check and review the related logic from issue #1391. Reproduce the reported handling of targets beginning with @@//, then verify that the check still catches fragile external repository strings while accepting the main-repository form.

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
Active
Clarity
Mostly clear
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.