From fb85207e34656b1b6fb5dfeec523a2b25d2e184c Mon Sep 17 00:00:00 2001 From: umarcor <unai.martinezcorral@ehu.eus> Date: Mon, 22 Aug 2022 02:29:06 +0200 Subject: [PATCH 1/7] golangci: enable 'gosimple' --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index a618ec24..7f724cc2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -37,7 +37,7 @@ linters: #- gomnd #- goprintffuncname #- gosec - #- gosimple + - gosimple - govet - ineffassign - interfacer From 4e2204874e80e8ec9cdc3a9095fb7e939cdf3ec6 Mon Sep 17 00:00:00 2001 From: umarcor <unai.martinezcorral@ehu.eus> Date: Mon, 22 Aug 2022 02:34:50 +0200 Subject: [PATCH 2/7] golangci: enable 'staticcheck' --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 7f724cc2..ff4372e8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -50,7 +50,7 @@ linters: #- nolintlint #- rowserrcheck #- scopelint - #- staticcheck + - staticcheck #- structcheck ! deprecated since v1.49.0; replaced by 'unused' #- stylecheck #- typecheck From 62eecc81757e073c04442f73821176f263363c2a Mon Sep 17 00:00:00 2001 From: umarcor <unai.martinezcorral@ehu.eus> Date: Mon, 22 Aug 2022 02:35:41 +0200 Subject: [PATCH 3/7] golangci: enable 'typecheck' --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index ff4372e8..671a02d3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -53,7 +53,7 @@ linters: - staticcheck #- structcheck ! deprecated since v1.49.0; replaced by 'unused' #- stylecheck - #- typecheck + - typecheck - unconvert #- unparam - unused From fca1d615288186e000dcfc7fd886af034bbc2acc Mon Sep 17 00:00:00 2001 From: umarcor <unai.martinezcorral@ehu.eus> Date: Mon, 22 Aug 2022 02:30:49 +0200 Subject: [PATCH 4/7] golangci: enable 'gofmt' --- .golangci.yml | 2 +- Makefile | 20 ++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 671a02d3..2de32fcb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -31,7 +31,7 @@ linters: - goconst #- gocritic #- gocyclo - #- gofmt + - gofmt - goimports - golint #- gomnd diff --git a/Makefile b/Makefile index 0da8d7aa..8e9b796d 100644 --- a/Makefile +++ b/Makefile @@ -5,19 +5,15 @@ ifeq (, $(shell which golangci-lint)) $(warning "could not find golangci-lint in $(PATH), run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh") endif -.PHONY: fmt lint test install_deps clean +.PHONY: lint test install_deps clean default: all -all: fmt test +all: test -fmt: - $(info ******************** checking formatting ********************) - @test -z $(shell gofmt -l $(SRC)) || (gofmt -d $(SRC); exit 1) - -lint: - $(info ******************** running lint tools ********************) - golangci-lint run -v +install_deps: + $(info ******************** downloading dependencies ********************) + go get -v ./... test: install_deps $(info ******************** running tests ********************) @@ -27,9 +23,9 @@ richtest: install_deps $(info ******************** running tests with kyoh86/richgo ********************) richgo test -v ./... -install_deps: - $(info ******************** downloading dependencies ********************) - go get -v ./... +lint: + $(info ******************** running lint tools ********************) + golangci-lint run -v clean: rm -rf $(BIN) From 287f2e992365e41fbaeaafa8053c19f5736bc7e2 Mon Sep 17 00:00:00 2001 From: umarcor <unai.martinezcorral@ehu.eus> Date: Mon, 22 Aug 2022 02:49:19 +0200 Subject: [PATCH 5/7] golangci: update list of available linters --- .golangci.yml | 108 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 83 insertions(+), 25 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2de32fcb..a0138383 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,47 +16,105 @@ run: deadline: 5m linters: + fast: false disable-all: true enable: - #- bodyclose + # Enabled by Default # - deadcode ! deprecated since v1.49.0; replaced by 'unused' - #- depguard - #- dogsled - #- dupl - errcheck - #- exhaustive - #- funlen - - gas - #- gochecknoinits - - goconst - #- gocritic - #- gocyclo - - gofmt - - goimports - - golint - #- gomnd - #- goprintffuncname - #- gosec - gosimple - govet - ineffassign - - interfacer + - staticcheck + - typecheck + - unused + # - varcheck ! deprecated since v1.49.0; replaced by 'unused' + # Disabled by Default + #- asasalint + #- asciicheck + #- bidichk + #- bodyclose + #- containedctx + #- contextcheck + #- cyclop + #- decorder + #- depguard + #- dogsled + #- dupl + #- durationcheck + #- errchkjson + #- errname + #- errorlint + #- execinquery + #- exhaustive + #- exhaustivestruct ! + #- exhaustruct + #- exportloopref + #- forbidigo + #- forcetypeassert + #- funlen + - gas + #- gci + #- gochecknoglobals + #- gochecknoinits + #- gocognit + - goconst + #- gocritic + #- gocyclo + #- godot + #- godox + #- goerr113 + - gofmt + #- gofumpt + #- goheader + - goimports + - golint # ! + #- gomnd + #- gomoddirectives + #- gomodguard + #- goprintffuncname + #- gosec + #- grouper + #- ifshort ! + #- importas + - interfacer # ! + #- ireturn #- lll - - maligned + #- maintidx + #- makezero + - maligned # ! - megacheck #- misspell #- nakedret + #- nestif + #- nilerr + #- nilnil + #- nlreturn #- noctx #- nolintlint + #- nonamedreturns + #- nosnakecase ! + #- nosprintfhostport + #- paralleltest + #- prealloc + #- predeclared + #- promlinter + #- revive #- rowserrcheck - #- scopelint - - staticcheck + #- scopelint ! + #- sqlclosecheck #- structcheck ! deprecated since v1.49.0; replaced by 'unused' #- stylecheck - - typecheck + #- tagliatelle + #- tenv + #- testpackage + #- thelper + #- tparallel - unconvert #- unparam - - unused - # - varcheck ! deprecated since v1.49.0; replaced by 'unused' + #- usestdlibvars + #- varnamelen + #- wastedassign #- whitespace - fast: false + #- wrapcheck + #- wsl From c056decb48e24e049db1fac2f0549c7c8f97952f Mon Sep 17 00:00:00 2001 From: umarcor <unai.martinezcorral@ehu.eus> Date: Mon, 22 Aug 2022 02:54:08 +0200 Subject: [PATCH 6/7] golangci: use 'revive' instead of 'golint' --- .golangci.yml | 4 ++-- completions_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a0138383..0f5aaa0d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -68,7 +68,7 @@ linters: #- gofumpt #- goheader - goimports - - golint # ! + #- golint ! Use revive instead #- gomnd #- gomoddirectives #- gomodguard @@ -99,7 +99,7 @@ linters: #- prealloc #- predeclared #- promlinter - #- revive + - revive #- rowserrcheck #- scopelint ! #- sqlclosecheck diff --git a/completions_test.go b/completions_test.go index 01724660..28a2c26b 100644 --- a/completions_test.go +++ b/completions_test.go @@ -1261,7 +1261,7 @@ func TestValidArgsFuncCmdContext(t *testing.T) { } rootCmd.AddCommand(childCmd) - //nolint:golint,staticcheck // We can safely use a basic type as key in tests. + //nolint:golint,revive,staticcheck // We can safely use a basic type as key in tests. ctx := context.WithValue(context.Background(), "testKey", "123") // Test completing an empty string on the childCmd From cee7f37a01adf9eace47c4597d39370ab2f6de53 Mon Sep 17 00:00:00 2001 From: umarcor <unai.martinezcorral@ehu.eus> Date: Mon, 22 Aug 2022 02:56:08 +0200 Subject: [PATCH 7/7] golangci: maligned is archived --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 0f5aaa0d..dad30b9d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -82,7 +82,7 @@ linters: #- lll #- maintidx #- makezero - - maligned # ! + #- maligned # Replaced by govet 'fieldalignment' - megacheck #- misspell #- nakedret