Skip to content

Commit 261d64e

Browse files
author
Ryan Cox
committed
port to golangci and make travisci improvements
1 parent 9c8302b commit 261d64e

File tree

3 files changed

+43
-49
lines changed

3 files changed

+43
-49
lines changed

.golangci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
run:
2+
deadline: 5m
3+
4+
linters:
5+
disable-all: true
6+
enable:
7+
- dupl
8+
- goconst
9+
- gocyclo
10+
- gofmt
11+
- golint
12+
- govet
13+
- ineffassign
14+
- interfacer
15+
- lll
16+
- misspell
17+
- nakedret
18+
- structcheck
19+
- unparam
20+
- varcheck
21+
22+
linters-settings:
23+
dupl:
24+
threshold: 400
25+
lll:
26+
line-length: 170
27+
gocyclo:
28+
min-complexity: 15
29+
golint:
30+
min-confidence: 0.85

.travis.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ go:
55

66
go_import_path: sigs.k8s.io/kustomize
77

8+
sudo: false
9+
10+
# Only clone the most recent commit.
11+
git:
12+
depth: 1
13+
14+
env:
15+
- GOLANGCI_RELEASE="v1.10.2"
16+
817
before_install:
918
- source ./bin/consider-early-travis-exit.sh
10-
- sudo apt-get install tree
11-
- go get -u github.com/golang/lint/golint
12-
- go get -u golang.org/x/tools/cmd/goimports
13-
- go get -u github.com/onsi/ginkgo/ginkgo
19+
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin ${GOLANGCI_RELEASE}
1420
- go get -u github.com/monopole/mdrip
15-
- go get -u github.com/fzipp/gocyclo
16-
- go get -u gopkg.in/alecthomas/gometalinter.v2 && gometalinter.v2 --install
1721

1822
# Install must be set to prevent default `go get` to run.
1923
# The dependencies have already been vendored by `dep` so

bin/pre-commit.sh

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ cd "$base_dir" || {
1111

1212
rc=0
1313

14-
function go_dirs {
15-
go list -f '{{.Dir}}' ./... | tail -n +2 | tr '\n' '\0'
16-
}
17-
1814
function runTest {
1915
local name=$1
2016
local result="SUCCESS"
@@ -28,40 +24,8 @@ function runTest {
2824
printf "============== end %s : %s code=%d\n\n\n" "$name" "$result" $code
2925
}
3026

31-
function testGoFmt {
32-
diff <(echo -n) <(go_dirs | xargs -0 gofmt -s -d -l)
33-
}
34-
35-
36-
function testGoCyclo {
37-
diff <(echo -n) <(go_dirs | xargs -0 gocyclo -over 15)
38-
}
39-
40-
function testGoLint {
41-
diff -u <(echo -n) <(go_dirs | xargs -0 golint --min_confidence 0.85 )
42-
}
43-
44-
# Not using the 'goimports' check because it reports hyphens in imported
45-
# package names as errors, and we vendor in packages that have
46-
# hyphens in their names.
47-
function testGoMetalinter {
48-
diff -u <(echo -n) <(go_dirs | xargs -0 gometalinter.v2 --disable-all --deadline 5m \
49-
--enable=misspell \
50-
--enable=structcheck \
51-
--enable=deadcode \
52-
--enable=varcheck \
53-
--enable=goconst \
54-
--enable=unparam \
55-
--enable=ineffassign \
56-
--enable=nakedret \
57-
--enable=interfacer \
58-
--enable=misspell \
59-
--line-length=170 --enable=lll \
60-
--dupl-threshold=400 --enable=dupl)
61-
}
62-
63-
function testGoVet {
64-
go vet -all ./...
27+
function testGoLangCILint {
28+
golangci-lint run ./...
6529
}
6630

6731
function testGoTest {
@@ -72,11 +36,7 @@ function testExamples {
7236
mdrip --mode test --label test README.md ./examples
7337
}
7438

75-
runTest testGoFmt
76-
runTest testGoMetalinter
77-
runTest testGoLint
78-
runTest testGoVet
79-
runTest testGoCyclo
39+
runTest testGoLangCILint
8040
runTest testGoTest
8141
runTest testExamples
8242

0 commit comments

Comments
 (0)