diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-03-02 10:53:13 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-03-02 11:41:21 +0300 |
commit | d7a5f22faf841819669d29ccf4e431fc3b2d9b76 (patch) | |
tree | a1002bae46450a9974609ee9ec3995f5c3d8d384 /tools/golangci-lint/gitaly/lint.go | |
parent | c7695bd902060be80b3499ffd2bd9e86d89c4f4f (diff) |
tools: Fix incompatible dependencies for new Gitaly linter
In d1c74493a (Add golangci-lint custom linter infrastructure,
2023-02-15), we have added a Gitaly-specific custom linter that is
plugged into golangci-lint. For the time being, we agreed to just make
it use the same `go.mod` as the main module, mostly because we wanted
`make test` to also execute its tests.
This is causing problems already, though. The Renovate bot has decided
to immediately try and upgrade the new dependency on golang.org/x/tools
to the most recent version. But this causes CI failures now because
golangci-lint requires all plugins to always use the same version of
that package as it uses itself.
Fix this by moving the Gitaly-specific linting infrastructure into a
subpackage of `tools/golangci-lint` and make it reuse the `go.mod` file.
This ensures that they always use compatible versions and that the main
production-level `go.mod` file is not tied to a specific dependency
version.
Diffstat (limited to 'tools/golangci-lint/gitaly/lint.go')
-rw-r--r-- | tools/golangci-lint/gitaly/lint.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/golangci-lint/gitaly/lint.go b/tools/golangci-lint/gitaly/lint.go new file mode 100644 index 000000000..f03e118eb --- /dev/null +++ b/tools/golangci-lint/gitaly/lint.go @@ -0,0 +1,29 @@ +package main + +import ( + "golang.org/x/tools/go/analysis" +) + +type analyzerPlugin struct{} + +func (*analyzerPlugin) GetAnalyzers() []*analysis.Analyzer { + return []*analysis.Analyzer{ + NewQuoteInterpolationAnalyzer([]string{ + "fmt.*", + }), + NewErrorWrapAnalyzer([]string{ + "fmt.Errorf", + "gitlab.com/gitlab-org/gitaly/v15/internal/structerr.*", + }), + } +} + +// AnalyzerPlugin is a convention of golangci-lint to implement a custom linter. This variable +// must implement `AnalyzerPlugin` interface: +// +// type AnalyzerPlugin interface { +// GetAnalyzers() []*analysis.Analyzer +// } +// +// For more information, please visit https://golangci-lint.run/contributing/new-linters/ +var AnalyzerPlugin analyzerPlugin |