From 2ebc9d7202f9c43306c11944b4ac9aa7515d77fe Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 9 Mar 2021 19:46:18 +0100 Subject: [PATCH] dev: clean configuration and code (#1830) --- .golangci.yml | 26 ------------------- pkg/config/config_gocritic.go | 3 +-- pkg/config/config_gocritic_test.go | 4 +-- pkg/golinters/depguard.go | 2 +- pkg/golinters/goanalysis/adapters.go | 2 +- pkg/golinters/gochecknoglobals.go | 3 +-- pkg/golinters/unparam.go | 3 +-- pkg/result/processors/max_from_linter_test.go | 1 - pkg/result/processors/processor_test.go | 4 +-- scripts/expand_website_templates/main.go | 1 - test/testdata/fix/in/gofumpt.go | 2 +- test/testdata/fix/out/gofumpt.go | 2 +- 12 files changed, 11 insertions(+), 42 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d625ff8047d8..0dc9ad903492 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -133,35 +133,9 @@ issues: - gocritic text: "unnecessaryDefer:" - # TODO temporary rule, must be removed - # seems related to v0.34.1, but I was not able to reproduce locally, - # I was also not able to reproduce in the CI of a fork, - # only the golangci-lint CI seems to be affected by this invalid analysis. - - path: pkg/golinters/scopelint.go - text: 'directive `//nolint:interfacer` is unused for linter interfacer' - - # TODO temporary rule, must be removed - # related to https://github.com/golangci/golangci-lint/pull/1756 - # must be replaced by '//nolint:staticcheck // require changes in github.com/OpenPeeDeeP/depguard' - - path: pkg/golinters/depguard.go - text: 'SA1019: package golang.org/x/tools/go/loader is deprecated' - - # TODO temporary rule, must be removed - # related to https://github.com/golangci/golangci-lint/pull/1756 - # must be replaced by '///nolint:staticcheck // it's an adapter for golang.org/x/tools/go/packages' - - path: pkg/golinters/goanalysis/adapters.go - text: 'SA1019: package golang.org/x/tools/go/loader is deprecated' - run: skip-dirs: - test/testdata_etc - internal/cache - internal/renameio - internal/robustio - -# golangci.com configuration -# https://github.com/golangci/golangci/wiki/Configuration -service: - golangci-lint-version: 1.23.x # use the fixed version to not introduce new linters unexpectedly - prepare: - - echo "here I can run custom commands, but no preparation needed for this repo" diff --git a/pkg/config/config_gocritic.go b/pkg/config/config_gocritic.go index ac0d6445d79d..34f850758144 100644 --- a/pkg/config/config_gocritic.go +++ b/pkg/config/config_gocritic.go @@ -5,11 +5,10 @@ import ( "sort" "strings" + _ "github.com/go-critic/go-critic/checkers" // this import register checkers "github.com/go-critic/go-critic/framework/linter" "github.com/pkg/errors" - _ "github.com/go-critic/go-critic/checkers" // this import register checkers - "github.com/golangci/golangci-lint/pkg/logutils" ) diff --git a/pkg/config/config_gocritic_test.go b/pkg/config/config_gocritic_test.go index 8096994bfa1f..98ad608e0a87 100644 --- a/pkg/config/config_gocritic_test.go +++ b/pkg/config/config_gocritic_test.go @@ -5,9 +5,9 @@ import ( "sort" "testing" - "github.com/golangci/golangci-lint/pkg/logutils" - "github.com/stretchr/testify/assert" + + "github.com/golangci/golangci-lint/pkg/logutils" ) func TestUtils(t *testing.T) { diff --git a/pkg/golinters/depguard.go b/pkg/golinters/depguard.go index 3bd854811009..aa372e9568c0 100644 --- a/pkg/golinters/depguard.go +++ b/pkg/golinters/depguard.go @@ -7,7 +7,7 @@ import ( "github.com/OpenPeeDeeP/depguard" "golang.org/x/tools/go/analysis" - "golang.org/x/tools/go/loader" + "golang.org/x/tools/go/loader" //nolint:staticcheck // require changes in github.com/OpenPeeDeeP/depguard "github.com/golangci/golangci-lint/pkg/golinters/goanalysis" "github.com/golangci/golangci-lint/pkg/lint/linter" diff --git a/pkg/golinters/goanalysis/adapters.go b/pkg/golinters/goanalysis/adapters.go index 830c4d8822da..b702d1660bac 100644 --- a/pkg/golinters/goanalysis/adapters.go +++ b/pkg/golinters/goanalysis/adapters.go @@ -4,7 +4,7 @@ import ( "go/types" "golang.org/x/tools/go/analysis" - "golang.org/x/tools/go/loader" + "golang.org/x/tools/go/loader" //nolint:staticcheck // it's an adapter for golang.org/x/tools/go/packages ) func MakeFakeLoaderProgram(pass *analysis.Pass) *loader.Program { diff --git a/pkg/golinters/gochecknoglobals.go b/pkg/golinters/gochecknoglobals.go index 37fed44849a9..804865cfcbaf 100644 --- a/pkg/golinters/gochecknoglobals.go +++ b/pkg/golinters/gochecknoglobals.go @@ -1,9 +1,8 @@ package golinters import ( - "golang.org/x/tools/go/analysis" - "4d63.com/gochecknoglobals/checknoglobals" + "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/pkg/golinters/goanalysis" ) diff --git a/pkg/golinters/unparam.go b/pkg/golinters/unparam.go index fabb6b527a09..33dd55c9b284 100644 --- a/pkg/golinters/unparam.go +++ b/pkg/golinters/unparam.go @@ -3,10 +3,9 @@ package golinters import ( "sync" - "golang.org/x/tools/go/packages" - "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/buildssa" + "golang.org/x/tools/go/packages" "mvdan.cc/unparam/check" "github.com/golangci/golangci-lint/pkg/golinters/goanalysis" diff --git a/pkg/result/processors/max_from_linter_test.go b/pkg/result/processors/max_from_linter_test.go index 7690bdf46533..7f5c9bcab107 100644 --- a/pkg/result/processors/max_from_linter_test.go +++ b/pkg/result/processors/max_from_linter_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/golangci/golangci-lint/pkg/config" - "github.com/golangci/golangci-lint/pkg/logutils" ) diff --git a/pkg/result/processors/processor_test.go b/pkg/result/processors/processor_test.go index 02e7a666aac4..ef9117416255 100644 --- a/pkg/result/processors/processor_test.go +++ b/pkg/result/processors/processor_test.go @@ -4,9 +4,9 @@ import ( "go/token" "testing" - "github.com/golangci/golangci-lint/pkg/result" - "github.com/stretchr/testify/assert" + + "github.com/golangci/golangci-lint/pkg/result" ) type issueTestCase struct { diff --git a/scripts/expand_website_templates/main.go b/scripts/expand_website_templates/main.go index edc1dec3c2dd..84057b23a271 100644 --- a/scripts/expand_website_templates/main.go +++ b/scripts/expand_website_templates/main.go @@ -17,7 +17,6 @@ import ( "strings" "github.com/golangci/golangci-lint/internal/renameio" - "github.com/golangci/golangci-lint/pkg/lint/linter" "github.com/golangci/golangci-lint/pkg/lint/lintersdb" ) diff --git a/test/testdata/fix/in/gofumpt.go b/test/testdata/fix/in/gofumpt.go index 762bfb4d7dbe..0870f31fa674 100644 --- a/test/testdata/fix/in/gofumpt.go +++ b/test/testdata/fix/in/gofumpt.go @@ -1,6 +1,6 @@ //args: -Egofumpt //config: linters-settings.gofumpt.extra-rules=true -package testdata +package p import "fmt" diff --git a/test/testdata/fix/out/gofumpt.go b/test/testdata/fix/out/gofumpt.go index 927ac34b75f2..0ae95af95dee 100644 --- a/test/testdata/fix/out/gofumpt.go +++ b/test/testdata/fix/out/gofumpt.go @@ -1,6 +1,6 @@ // args: -Egofumpt // config: linters-settings.gofumpt.extra-rules=true -package testdata +package p import "fmt"