fzipp / gocyclo

Calculate cyclomatic complexities of functions in Go source code.
BSD 3-Clause "New" or "Revised" License
1.33k stars 81 forks source link

gocycle with -over flag throws exist status code that causes automated build to fail. #18

Closed introllo closed 7 years ago

introllo commented 7 years ago

Calling gocyclo from a build chain: TeamCity -> sonar-golang -> gometalinter -> gosimple.

Gocycle throws an exit code of 1 for -over flag. This causes downstream confusion. ie, the build "fails" when it catches the exit as "1". How can I further debug this?

root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# pwd /root/go/src/private-domain/repo/app.git

root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# go version go version go1.8 linux/amd64

root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# go env GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/root/go" GORACE="" GOROOT="/usr/go" GOTOOLDIR="/usr/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build008283540=/tmp/go-build -gno-record-gcc-switches" CXX="g++" CGO_ENABLED="1" PKG_CONFIG="pkg-config" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2"

root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# gocyclo .
20 main main app.go:42:1 2 main TestReturnTrueOnValidInt app_test.go:14:1 2 main TestReturnTrueOnValidString app_test.go:7:1 2 main validateIntFlag app.go:166:1 2 main validateStringFlag app.go:157:1 1 main usage app.go:14:1 root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# echo $? 0

root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# gocyclo -over 20 . root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# echo $? 0

root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# gocyclo -over 19 . 20 main main app.go:42:1 root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# echo $? 1

root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# gocyclo -over 2 . 20 main main app.go:42:1 root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# echo $? 1

root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# gocyclo -over 1 . 20 main main app.go:42:1 2 main TestReturnTrueOnValidInt app_test.go:14:1 2 main TestReturnTrueOnValidString app_test.go:7:1 2 main validateIntFlag app.go:166:1 2 main validateStringFlag app.go:157:1 root@1b8705ad04c3:~/go/src/private-domain/repo/app.git# echo $? 1

introllo commented 7 years ago

On further review, I see this is expected actually as the exit status indicates a "hit". Will handle this downstream in configuration. Thx.