github.com/turingchain2020/turingchain@v1.1.21/golinter.sh (about) 1 #!/bin/bash 2 # shellcheck disable=SC2207 3 set +e 4 5 OP="${1}" 6 path="${2}" 7 8 function filterLinter() { 9 res=$( 10 golangci-lint run --no-config --issues-exit-code=1 --deadline=2m --disable-all \ 11 --enable=gofmt \ 12 --enable=gosimple \ 13 --enable=deadcode \ 14 --enable=unconvert \ 15 --enable=interfacer \ 16 --enable=varcheck \ 17 --enable=structcheck \ 18 --enable=goimports \ 19 --enable=misspell \ 20 --enable=golint \ 21 --exclude=underscores \ 22 --exclude-use-default=false 23 ) 24 # --enable=staticcheck \ 25 # --enable=gocyclo \ 26 # --enable=staticcheck \ 27 # --enable=golint \ 28 # --enable=unused \ 29 # --enable=gotype \ 30 # --enable=gotypex \ 31 32 # if [[ ${#res} -gt "0" ]]; then 33 # resNoSpace=$(echo "${res}" | tr ' ' '@') 34 # array=($(echo "${resNoSpace}" | tr '\n' '\n')) 35 # str="" 36 # for var in ${array[*]}; do 37 # if ! [[ $var =~ "underscores" ]]; then 38 # str="${str}""${var}""\\n" 39 # fi 40 # done 41 # res="" 42 # res=$(echo "${str}" | tr '@' ' ') 43 # fi 44 if [[ ${#res} -gt "0" ]]; then 45 echo -e "${res}" 46 exit 1 47 fi 48 } 49 50 function testLinter() { 51 cd "${path}" >/dev/null || exit 52 golangci-lint run --no-config --issues-exit-code=1 --deadline=2m --disable-all \ 53 --enable=gofmt \ 54 --enable=gosimple \ 55 --enable=deadcode \ 56 --enable=unconvert \ 57 --enable=interfacer \ 58 --enable=varcheck \ 59 --enable=structcheck \ 60 --enable=goimports \ 61 --enable=misspell \ 62 --enable=golint \ 63 --exclude=underscores \ 64 --exclude-use-default=false 65 66 cd - >/dev/null || exit 67 } 68 69 function main() { 70 if [ "${OP}" == "filter" ]; then 71 filterLinter 72 elif [ "${OP}" == "test" ]; then 73 testLinter 74 fi 75 } 76 77 # run script 78 main