backend-lint.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. function exit_if_fail {
  3. command=$@
  4. echo "Executing '$command'"
  5. eval $command
  6. rc=$?
  7. if [ $rc -ne 0 ]; then
  8. echo "'$command' returned $rc."
  9. exit $rc
  10. fi
  11. }
  12. go get -u github.com/alecthomas/gometalinter
  13. go get -u github.com/jgautheron/goconst/cmd/goconst
  14. go get -u honnef.co/go/tools/cmd/staticcheck
  15. go get -u github.com/mgechev/revive
  16. go get -u github.com/securego/gosec/cmd/gosec/...
  17. go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
  18. # use gometalinter when lints are not available in golangci or
  19. # when gometalinter is better. Eg. goconst for gometalinter does not lint test files
  20. # which is not desired.
  21. exit_if_fail gometalinter --enable-gc --vendor --deadline 10m --disable-all \
  22. --enable=goconst\
  23. --enable=staticcheck
  24. # use golangci-when possible
  25. exit_if_fail golangci-lint run --deadline 10m --disable-all \
  26. --enable=deadcode\
  27. --enable=gofmt\
  28. --enable=ineffassign\
  29. --enable=structcheck\
  30. --enable=unconvert\
  31. --enable=varcheck
  32. exit_if_fail go vet ./pkg/...
  33. exit_if_fail revive -formatter stylish -config ./scripts/revive.toml
  34. # TODO recheck the rules and leave only necessary exclusions
  35. exit_if_fail gosec -quiet -exclude=G104,G107,G201,G202,G204,G301,G302,G304,G402,G501,G505,G401 ./pkg/...