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

gocyclo doesn't skip testdata directories #6

Closed kostya-sh closed 6 years ago

kostya-sh commented 8 years ago

As result it fails if there an invalid test go file in one of testdata directories

weberc2 commented 8 years ago

Are 'testdata' directories part of the Go spec? Or how should this tool know what directories are for test data?

kostya-sh commented 8 years ago

@weberc2, it is not part of Go language spec. This is behavior of go build tool. It is mentioned in the documentation - https://golang.org/cmd/go/#hdr-Description_of_package_lists

The only other build tool for Go that I am aware of (gb) also works the same way.

xianhammer commented 7 years ago

The go build tool disregard files ending with "_test.go" so a very simple code change allow for filtering out test code. Personally I am both pro and con allowing such filtering as test code is in a grey zone - should it or shouldn't it live up to same standards as "real code". Many of the go tools does not consider test code (files) to be in the same league... Regardless of perspective an option allowing to filter out "_test.go" files would be beneficial. If requested I can apply a working update (by either mail or commit)