Skip to content

Commit

Permalink
Let nogo linters use the right golang.org/x/tools dependency
Browse files Browse the repository at this point in the history
Instruct gazelle with an explicit mapping directive to use the right
golang.org/x/tools dependency for the Analyzer interface which is also
used by nogo to load the custom analyzers.

Since gazelle now does the correct mapping, all special handling of
files with a `#gazelle: ignore` annotation is no longer necessary.

The BUILD.bazel files for analyzers are now generated like all the other
build files.

Signed-off-by: Roman Mohr <[email protected]>
  • Loading branch information
rmohr committed Jul 5, 2022
1 parent 0245e9f commit cde0e57
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ nogo(

# gazelle:prefix kubevirt.io/kubevirt
# gazelle:build_tags selinux
# gazelle:resolve go golang.org/x/tools/go/analysis @org_golang_x_tools//go/analysis:go_default_library
gazelle(
name = "gazelle",
build_tags = ["selinux"],
Expand Down
15 changes: 0 additions & 15 deletions hack/bazel-generate.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
#!/usr/bin/env bash

# first ensure this file, so that sandbox bootstrapping has a working nogo setup
# without this sourcing hack/bootstraph.sh will fail
cat >vendor/github.com/gordonklaus/ineffassign/pkg/ineffassign/BUILD.bazel <<EOT
# gazelle:ignore
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["ineffassign.go"],
importmap = "kubevirt.io/kubevirt/vendor/github.com/gordonklaus/ineffassign/pkg/ineffassign",
importpath = "github.com/gordonklaus/ineffassign/pkg/ineffassign",
visibility = ["//visibility:public"],
deps = ["@org_golang_x_tools//go/analysis:go_default_library"],
)
EOT

source hack/common.sh
source hack/bootstrap.sh
source hack/config.sh
Expand Down
13 changes: 5 additions & 8 deletions tools/analyzers/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# gazelle:ignore
load("@io_bazel_rules_go//go:def.bzl", "go_tool_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_tool_library(
name = "ineffassign",
go_library(
name = "go_default_library",
srcs = ["analyzer.go"],
importpath = "kubevirt.io/kubevirt/analyzer",
importpath = "kubevirt.io/kubevirt/tools/analyzers",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/gordonklaus/ineffassign/pkg/ineffassign:go_tool_library",
],
deps = ["//vendor/github.com/gordonklaus/ineffassign/pkg/ineffassign:go_default_library"],
)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cde0e57

Please sign in to comment.