sourcegraph/dev/linters/staticcheck
2024-05-16 15:51:16 +01:00
..
cmd bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
analyzers.bzl build: add buildifier check to Aspect Workflows (#58566) 2023-11-27 14:58:01 +02:00
BUILD.bazel bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
README.md bazel: add staticcheck analyzers (#50386) 2023-04-11 10:02:25 +02:00
staticcheck.go bazel: migrate go:generate for staticcheck (#59215) 2024-01-02 13:02:50 +00:00
targets.bzl bazel: migrate go:generate for staticcheck (#59215) 2024-01-02 13:02:50 +00:00

Static check analyzers

We cannot use the staticcheck analyzer directly, since it's actually a collection of analyzers. So we have to pull out each "micro" analyzer and create a seperate bazel target with it.

Each bazel target actually just uses staticcheck.go and embeds the analyzer it SHOULD use when invoked as that target. Ex:

bazel build //dev/linters/staticcheck:SA6001 The above target will do the following:

Set AnalyzerName to SA6001 in staticcheck.go uses x_def Set the importpath to github.com/sourcegraph/sourcegraph/dev/llinters/staticcheck/SA6001. This is very important, otherwise there won't be different libraries with different analyzer names, just one library with one analyzer set invoked by different targets.

How to regenerate the analyzers

To regenerate the BUILD.bazel and analyzer.bzl files run go generate in dev/linters/staticcheck. This effectively runs go run ./cmd/gen.go