backend-lint.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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/tsenart/deadcode
  14. go get -u github.com/jgautheron/goconst/cmd/goconst
  15. go get -u github.com/gordonklaus/ineffassign
  16. go get -u github.com/opennota/check/cmd/structcheck
  17. go get -u github.com/mdempsky/unconvert
  18. go get -u github.com/opennota/check/cmd/varcheck
  19. go get -u honnef.co/go/tools/cmd/staticcheck
  20. go get -u github.com/mgechev/revive
  21. go get -u github.com/securego/gosec/cmd/gosec/...
  22. exit_if_fail gometalinter --enable-gc --vendor --deadline 10m --disable-all \
  23. --enable=deadcode \
  24. --enable=goconst \
  25. --enable=gofmt \
  26. --enable=ineffassign \
  27. --enable=structcheck \
  28. --enable=unconvert \
  29. --enable=varcheck \
  30. --enable=staticcheck
  31. exit_if_fail go vet ./pkg/...
  32. exit_if_fail revive -formatter stylish -config ./conf/revive.toml
  33. # TODO recheck the rules and leave only necessary exclusions
  34. exit_if_fail gosec -quiet -exclude=G104,G107,G201,G202,G204,G301,G302,G304,G402,G501,G505,G401 ./pkg/...