build: partially replace gometalinter with golangci-lint (#16610)

we still use gometalinter for goconst since it doesn't 
report errors for duplicated in test files
This commit is contained in:
Carl Bergquist
2019-04-16 10:27:07 +02:00
committed by GitHub
parent 406ef962fc
commit 490515aec6
7 changed files with 30 additions and 25 deletions
+24 -21
View File
@@ -1,39 +1,42 @@
#!/bin/bash
function exit_if_fail {
command=$@
echo "Executing '$command'"
eval $command
rc=$?
if [ $rc -ne 0 ]; then
echo "'$command' returned $rc."
exit $rc
fi
command=$@
echo "Executing '$command'"
eval $command
rc=$?
if [ $rc -ne 0 ]; then
echo "'$command' returned $rc."
exit $rc
fi
}
go get -u github.com/alecthomas/gometalinter
go get -u github.com/tsenart/deadcode
go get -u github.com/jgautheron/goconst/cmd/goconst
go get -u github.com/gordonklaus/ineffassign
go get -u github.com/opennota/check/cmd/structcheck
go get -u github.com/mdempsky/unconvert
go get -u github.com/opennota/check/cmd/varcheck
go get -u honnef.co/go/tools/cmd/staticcheck
go get -u github.com/mgechev/revive
go get -u github.com/securego/gosec/cmd/gosec/...
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
# use gometalinter when lints are not available in golangci or
# when gometalinter is better. Eg. goconst for gometalinter does not lint test files
# which is not desired.
exit_if_fail gometalinter --enable-gc --vendor --deadline 10m --disable-all \
--enable=deadcode \
--enable=goconst \
--enable=gofmt \
--enable=ineffassign \
--enable=structcheck \
--enable=unconvert \
--enable=varcheck \
--enable=goconst\
--enable=staticcheck
# use golangci-when possible
exit_if_fail golangci-lint run --deadline 10m --disable-all \
--enable=deadcode\
--enable=gofmt\
--enable=ineffassign\
--enable=structcheck\
--enable=unconvert\
--enable=varcheck
exit_if_fail go vet ./pkg/...
exit_if_fail revive -formatter stylish -config ./conf/revive.toml
exit_if_fail revive -formatter stylish -config ./scripts/revive.toml
# TODO recheck the rules and leave only necessary exclusions
exit_if_fail gosec -quiet -exclude=G104,G107,G201,G202,G204,G301,G302,G304,G402,G501,G505,G401 ./pkg/...
+27
View File
@@ -0,0 +1,27 @@
ignoreGeneratedHeader = false
severity = "error"
confidence = 0.8
errorCode = 0
[rule.context-as-argument]
[rule.error-return]
[rule.package-comments]
[rule.range]
[rule.superfluous-else]
[rule.modifies-parameter]
# This can be checked by other tools like megacheck
[rule.unreachable-code]
# Those are probably should be enabled at some point
# [rule.unexported-return]
# [rule.exported]
# [rule.var-naming]
# [error-naming]
# [rule.dot-imports]
# [blank-imports]
# [rule.receiver-naming]
# [error-strings]
# [rule.if-return]
# [rule.indent-error-flow]
# [rule.blank-imports]