Skip to content

Commit

Permalink
Merge pull request #494 from openSUSE/golangci-lint
Browse files Browse the repository at this point in the history
Move from gometalinter to golangci-lint
  • Loading branch information
k8s-ci-robot authored Aug 6, 2019
2 parents 7f76abe + 5ec5bfe commit e8559a8
Show file tree
Hide file tree
Showing 989 changed files with 204,009 additions and 4,918 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@
*.un~
Session.vim
.netrwhist

build
110 changes: 110 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
run:
concurrency: 6
deadline: 5m
linters:
disable-all: true
enable:
- depguard
- gofmt
- govet
- ineffassign
- nakedret
- structcheck
- typecheck
- varcheck
# - bodyclose
# - deadcode
# - dupl
# - errcheck
# - gochecknoglobals
# - gochecknoinits
# - goconst
# - gocritic
# - gocyclo
# - goimports
# - golint
# - gosec
# - gosimple
# - interfacer
# - lll
# - maligned
# - misspell
# - prealloc
# - scopelint
# - staticcheck
# - stylecheck
# - unconvert
# - unparam
# - unused
linters-settings:
gocritic:
enabled-checks:
# Diagnostic
- appendAssign
- argOrder
- badCond
- caseOrder
- codegenComment
- commentedOutCode
- deprecatedComment
- dupArg
- dupBranchBody
- dupCase
- dupSubExpr
- exitAfterDefer
- flagDeref
- flagName
- nilValReturn
- offBy1
- sloppyReassign
- weakCond
- octalLiteral

# Performance
- appendCombine
- equalFold
- hugeParam
- indexAlloc
- rangeExprCopy
- rangeValCopy

# Style
- assignOp
- boolExprSimplify
- captLocal
- commentFormatting
- commentedOutImport
- defaultCaseOrder
- docStub
- elseif
- emptyFallthrough
- emptyStringTest
- hexLiteral
- ifElseChain
- methodExprCall
- regexpMust
- singleCaseSwitch
- sloppyLen
- stringXbytes
- switchTrue
- typeAssertChain
- typeSwitchVar
- underef
- unlabelStmt
- unlambda
- unslice
- valSwap
- wrapperFunc
- yodaStyleExpr

# Opinionated
- builtinShadow
- importShadow
- initClause
- nestingReduce
- paramTypeCombine
- ptrToRefParam
- typeUnparen
- unnamedResult
- unnecessaryBlock
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ jobs:
os: linux
script:
- make lint
- make gofmt
- hack/verify-go-modules.sh
- stage: Static check
os: linux-ppc64le
script:
- make lint
- make gofmt
- hack/verify-go-modules.sh
- stage: Build
os: linux
Expand All @@ -56,13 +54,15 @@ jobs:
- make
- travis_wait hack/install-docker.sh
- travis_wait hack/install-kubelet.sh
- cp build/bin/ginkgo $GOPATH/bin
- sudo env PATH=$PATH GOPATH=$GOPATH hack/run-critest.sh
- stage: Test
os: linux-ppc64le
script:
- make
- travis_wait hack/install-docker.sh
- travis_wait hack/install-kubelet.sh
- cp build/bin/ginkgo $GOPATH/bin
- sudo env PATH=$PATH GOPATH=$GOPATH hack/run-critest.sh
- stage: Test
os: windows
Expand Down
31 changes: 20 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ VERSION := $(shell git describe --tags --dirty --always)
VERSION := $(VERSION:v%=%)
GO_LDFLAGS := -X $(PROJECT)/pkg/version.Version=$(VERSION)

BUILD_PATH := $(shell pwd)/build
BUILD_BIN_PATH := $(BUILD_PATH)/bin

define go-build
$(shell cd `pwd` && $(GO) build -o $(BUILD_BIN_PATH)/$(shell basename $(1)) $(1))
@echo > /dev/null
endef

GINKGO := $(BUILD_BIN_PATH)/ginkgo
GOLANGCI_LINT := $(BUILD_BIN_PATH)/golangci-lint

all: binaries

help:
Expand Down Expand Up @@ -85,22 +96,21 @@ uninstall-critest:
rm -f $(BINDIR)/critest

uninstall-crictl:
rm -f $(BINDIR)/crictl
rm -f $(BINDIR)/crictl

uninstall: uninstall-critest uninstall-crictl

lint:
./hack/repo-infra/verify/go-tools/verify-gometalinter.sh
./hack/repo-infra/verify/verify-go-src.sh -r $(shell pwd) -v
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run
./hack/repo-infra/verify/verify-boilerplate.sh

gofmt:
./hack/repo-infra/verify/go-tools/verify-gofmt.sh
install.tools: $(GOLANGCI_LINT) $(GINKGO)

$(GOLANGCI_LINT):
$(call go-build,./vendor/github.com/golangci/golangci-lint/cmd/golangci-lint)

install.tools:
go get -u github.com/onsi/ginkgo/ginkgo
go get -u github.com/alecthomas/gometalinter
gometalinter --install
$(GINKGO):
$(call go-build,./vendor/github.com/onsi/ginkgo/ginkgo)

release:
hack/release.sh
Expand All @@ -125,7 +135,6 @@ vendor:
uninstall-critest \
uninstall-crictl \
lint \
gofmt \
install.tools \
release \
vendor
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/ghodss/yaml v1.0.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/protobuf v1.3.2
github.com/golangci/golangci-lint v1.17.1
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.5.0
github.com/opencontainers/go-digest v1.0.0-rc1
Expand Down
Loading

0 comments on commit e8559a8

Please sign in to comment.