1
0
Fork 0
mirror of https://github.com/spf13/cobra synced 2025-04-07 07:19:16 +00:00
This commit is contained in:
Unai Martinez-Corral 2024-03-18 12:52:34 +08:00 committed by GitHub
commit 21c1eae09e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 82 additions and 28 deletions

View file

@ -16,47 +16,105 @@ run:
deadline: 5m deadline: 5m
linters: linters:
fast: false
disable-all: true disable-all: true
enable: enable:
#- bodyclose # Enabled by Default
# - deadcode ! deprecated since v1.49.0; replaced by 'unused' # - deadcode ! deprecated since v1.49.0; replaced by 'unused'
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
# - varcheck ! deprecated since v1.49.0; replaced by 'unused'
# Disabled by Default
#- asasalint
#- asciicheck
#- bidichk
#- bodyclose
#- containedctx
#- contextcheck
#- cyclop
#- decorder
#- depguard #- depguard
#- dogsled #- dogsled
#- dupl #- dupl
- errcheck #- durationcheck
#- errchkjson
#- errname
#- errorlint
#- execinquery
#- exhaustive #- exhaustive
#- exhaustivestruct !
#- exhaustruct
#- exportloopref
#- forbidigo
#- forcetypeassert
#- funlen #- funlen
- gas - gas
#- gci
#- gochecknoglobals
#- gochecknoinits #- gochecknoinits
#- gocognit
- goconst - goconst
#- gocritic #- gocritic
#- gocyclo #- gocyclo
#- gofmt #- godot
#- godox
#- goerr113
- gofmt
#- gofumpt
#- goheader
- goimports - goimports
- golint #- golint ! Use revive instead
#- gomnd #- gomnd
#- gomoddirectives
#- gomodguard
#- goprintffuncname #- goprintffuncname
#- gosec #- gosec
#- gosimple #- grouper
- govet #- ifshort !
- ineffassign #- importas
- interfacer - interfacer # !
#- ireturn
#- lll #- lll
- maligned #- maintidx
#- makezero
#- maligned # Replaced by govet 'fieldalignment'
- megacheck - megacheck
#- misspell #- misspell
#- nakedret #- nakedret
#- nestif
#- nilerr
#- nilnil
#- nlreturn
#- noctx #- noctx
#- nolintlint #- nolintlint
#- nonamedreturns
#- nosnakecase !
#- nosprintfhostport
#- paralleltest
#- prealloc
#- predeclared
#- promlinter
- revive
#- rowserrcheck #- rowserrcheck
#- scopelint #- scopelint !
#- staticcheck #- sqlclosecheck
#- structcheck ! deprecated since v1.49.0; replaced by 'unused' #- structcheck ! deprecated since v1.49.0; replaced by 'unused'
#- stylecheck #- stylecheck
#- typecheck #- tagliatelle
#- tenv
#- testpackage
#- thelper
#- tparallel
- unconvert - unconvert
#- unparam #- unparam
- unused #- usestdlibvars
# - varcheck ! deprecated since v1.49.0; replaced by 'unused' #- varnamelen
#- wastedassign
#- whitespace #- whitespace
fast: false #- wrapcheck
#- wsl

View file

@ -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") $(warning "could not find golangci-lint in $(PATH), run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh")
endif endif
.PHONY: fmt lint test install_deps clean .PHONY: lint test install_deps clean
default: all default: all
all: fmt test all: test
fmt: install_deps:
$(info ******************** checking formatting ********************) $(info ******************** downloading dependencies ********************)
@test -z $(shell gofmt -l $(SRC)) || (gofmt -d $(SRC); exit 1) go get -v ./...
lint:
$(info ******************** running lint tools ********************)
golangci-lint run -v
test: install_deps test: install_deps
$(info ******************** running tests ********************) $(info ******************** running tests ********************)
@ -27,9 +23,9 @@ richtest: install_deps
$(info ******************** running tests with kyoh86/richgo ********************) $(info ******************** running tests with kyoh86/richgo ********************)
richgo test -v ./... richgo test -v ./...
install_deps: lint:
$(info ******************** downloading dependencies ********************) $(info ******************** running lint tools ********************)
go get -v ./... golangci-lint run -v
clean: clean:
rm -rf $(BIN) rm -rf $(BIN)

View file

@ -1264,7 +1264,7 @@ func TestValidArgsFuncCmdContext(t *testing.T) {
} }
rootCmd.AddCommand(childCmd) 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") ctx := context.WithValue(context.Background(), "testKey", "123")
// Test completing an empty string on the childCmd // Test completing an empty string on the childCmd