Add a lint warning for external repository references and usage canonical repository names#1386
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…eleases/tag/v8.5.1 Broken by bazelbuild/buildtools#1386 PiperOrigin-RevId: 863149692 Change-Id: I81ca12ed891b539e0c4ccf133ffbc32478d80e43
|
With the release of buildtools 8.5.1 this is now in the wild. These new lints have caught have caught several problems but they've also hit several false positives.
Comment strings should be ignored, though I'm not sure how false positives in other places can be avoided (it may well be impossible). |
| if strings.Contains(stringExpr.Value, "@@") { | ||
| findings = append(findings, | ||
| makeLinterFinding(stringExpr, `String contains "@@" which indicates a canonical repository name reference that should be avoided.`)) | ||
| } |
There was a problem hiding this comment.
This warns on @@// which is the explicitly supported way to refer to the main repo from an external repo without having to use a name for the main repo.
In Bzlmod, the usage of canonical repository names should be avoided as it is not a public API makes BUILD files less portable. Developers also should never hardcode paths inside external repos.