Skip to content

gocyclo isn't run #722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LennyPenny opened this issue Sep 23, 2019 · 7 comments
Closed

gocyclo isn't run #722

LennyPenny opened this issue Sep 23, 2019 · 7 comments
Labels
feedback required Requires additional feedback stale No recent correspondence or work activity

Comments

@LennyPenny
Copy link

LennyPenny commented Sep 23, 2019

Thank you for creating the issue!

Version

golangci-lint has version v1.18.0 built from (unknown, mod sum: "h1:XmQgfcLofSG/6AsQuQqmLizB+3GggD+o6ObBG9L+VMM=") on (unknown)
  1. Config file:
linters:
  enable:
    - govet
    - errcheck
    - staticcheck
    - unused
    - gosimple
    - structcheck
    - varcheck
    - ineffassign
    - deadcode
    - typecheck
    - goconst
    - gofmt
    - goimports
    - gosec
    - gocyclo
linter-settings:
  gocyclo:
    min-complexity: 10
  1. Go environment:
$ go version && go env
go version go1.12.9 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/lenny/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/lenny/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/golang"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/lenny/go/src/gitlab.com/fino/uba/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build080054239=/tmp/go-build -gno-record-gcc-switches"

running gocyclo on its own results in results being shown, however running gocyclo through golangci-lint produces no output.

gocyclo output:

$ go run github.com/fzipp/gocyclo --over 10 xxx.go
19 handler yyy xxx.go:66:1
15 handler yyy xxx.go:314:1
15 handler yyy xxx.go:937:1
15 handler yyy xxx.go:673:1
13 handler yyy xxx.go:560:1
12 handler yyy xxx.go:1023:1
exit status 1

golangci-lint output:

$ ~/go/bin/golangci-lint run xxx.go -v
INFO [config_reader] Config search paths: [./ xxx /home/lenny/go/src/gitlab.com /home/lenny/go/src /home/lenny/go /home/lenny /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 15 linters: [deadcode errcheck goconst gocyclo gofmt goimports gosec gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [lintersdb] Optimized sublinters [staticcheck gosimple unused] into metalinter megacheck 
INFO [loader] Go packages loading at mode 991 (files|types_sizes|compiled_files|deps|types|types_info|imports|name|syntax) took 1.766214225s 
INFO [loader] SSA repr building timing: packages building 28.877015ms, total 308.18515ms 
INFO [runner] worker.4 took 1.536759ms with stages: deadcode: 736.627µs, structcheck: 468.443µs, goconst: 324.951µs 
INFO [runner] worker.8 took 1.928124ms with stages: varcheck: 1.05247ms, errcheck: 513.885µs, gocyclo: 346.077µs, typecheck: 2.515µs 
INFO [runner] worker.3 took 9.247182ms with stages: ineffassign: 9.238964ms 
INFO [runner] worker.1 took 10.98954ms with stages: gofmt: 10.98252ms 
xxx.go:777:30: Error return value of `yyy` is not checked (errcheck)
        yyy
                                    ^
INFO [runner] worker.2 took 52.407277ms with stages: goimports: 52.397205ms 
INFO [runner] worker.7 took 66.47593ms with stages: gosec: 66.466174ms 
INFO [runner] worker.6 took 175.513867ms with stages: govet: 175.501356ms 
INFO [runner] worker.5 took 899.517153ms with stages: megacheck: 899.510172ms 
INFO [runner] Workers idle times: #1: 888.495619ms, #2: 847.086282ms, #3: 890.188556ms, #4: 897.914577ms, #6: 723.967841ms, #7: 832.991121ms, #8: 897.538842ms 
INFO [runner] Issues before processing: 2, after processing: 1 
INFO [runner] processing took 21.742158ms with stages: autogenerated_exclude: 13.93719ms, nolint: 6.731718ms, source_code: 532.477µs, exclude: 252.718µs, identifier_marker: 150.613µs, skip_dirs: 49.274µs, uniq_by_line: 19.437µs, path_shortener: 14.452µs, cgo: 14.051µs, max_from_linter: 13.005µs, path_prettifier: 12.989µs, max_same_issues: 4.392µs, filename_unadjuster: 3.473µs, max_per_file_from_linter: 2.967µs, diff: 2.139µs, exclude-rules: 705ns, skip_files: 558ns 
INFO File cache stats: 1 entries of total size 38.4KiB 
INFO Memory: 30 samples, avg is 367.0MB, max is 743.8MB 
INFO Execution took 3.057199579s   

Expected output:
Same as gocyclo output

@jirfag jirfag added the bug Something isn't working label Sep 24, 2019
@pierrre
Copy link
Contributor

pierrre commented Sep 24, 2019

It still works for me:

testutils/compare.go:31:1: cyclomatic complexity 16 of func `comparef` is high (> 10) (gocyclo)

I'm using v1.18.0, pre-built binaries.

@tpounds tpounds added the feedback required Requires additional feedback label Oct 7, 2019
@tpounds
Copy link
Contributor

tpounds commented Oct 7, 2019

@LennyPenny Are you able to reproduce this issue if you only enable gocyclo and disable all others linters? I'm wondering if the reason gocyclo didn't trigger is because there are other errors detected by errcheck.

@LennyPenny
Copy link
Author

LennyPenny commented Oct 7, 2019

@tpounds nop, even with only gocyclo enabled I'm still getting no results

$ ~/go/bin/golangci-lint run xxx.go -v
INFO [config_reader] Config search paths: [./ /home/lenny/go/src/gitlab.com/fino/uba/pkg/http/rest/handler /home/lenny/go/src/gitlab.com/fino/uba/pkg/http/rest /home/lenny/go/src/gitlab.com/fino/uba/pkg/http /home/lenny/go/src/gitlab.com/fino/uba/pkg /home/lenny/go/src/gitlab.com/fino/uba /home/lenny/go/src/gitlab.com/fino /home/lenny/go/src/gitlab.com /home/lenny/go/src /home/lenny/go /home/lenny /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 1 linters: [gocyclo]      
INFO [loader] Go packages loading at mode 7 (compiled_files|files|name) took 242.700081ms 
INFO [runner] worker.2 took 75.001µs              
INFO [runner] worker.6 took 2.227µs               
INFO [runner] worker.3 took 1.785µs               
INFO [runner] worker.7 took 2.434µs               
INFO [runner] worker.8 took 2.308µs               
INFO [runner] worker.4 took 1.885µs               
INFO [runner] worker.1 took 583.991µs with stages: gocyclo: 574.726µs 
INFO [runner] worker.5 took 1.751µs               
INFO [runner] Workers idle times: #1: 29.095µs, #2: 430.702µs, #3: 280.376µs, #4: 66.266µs, #6: 348.974µs, #7: 203.423µs, #8: 133.716µs 
INFO [runner] processing took 5.512µs with stages: max_same_issues: 1.226µs, skip_dirs: 724ns, nolint: 546ns, max_from_linter: 478ns, cgo: 302ns, diff: 252ns, path_prettifier: 248ns, filename_unadjuster: 228ns, path_shortener: 227ns, autogenerated_exclude: 216ns, skip_files: 216ns, identifier_marker: 199ns, source_code: 189ns, max_per_file_from_linter: 130ns, exclude-rules: 113ns, exclude: 112ns, uniq_by_line: 106ns 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 5 samples, avg is 69.2MB, max is 69.4MB 
INFO Execution took 318.129723ms    

@jirfag
Copy link
Contributor

jirfag commented Oct 8, 2019

Hi.

  1. We need to make debug flag to output used config to be sure that the 10 threshold is used
  2. We should make a 1.20.0 where as I remember I have added logging of filters statistics. To be sure that some filter like auto generated didn’t filtered this out

@LennyPenny
Copy link
Author

Yea my current goal is to build a debug version of golangci-lint and breakpoint through to see whats actually going on. Might only be tomorrow tho

@unmultimedio
Copy link

unmultimedio commented Oct 17, 2019

Hello, having the same issue here:

➜  project git:(branch) ✗ gocyclo -over 5 ./controller
7 controller (fooController).fooMethod controller/foo.go:98:1
7 controller (barController).barMethod controller/bar.go:94:1
7 controller (bazController).bazMethod controller/baz.go:78:1

➜  project git:(branch) ✗ golangci-lint run -v --disable-all -E gocyclo ./controller
INFO [config_reader] Config search paths: [./ /Users/jfigueroa/go/src/foo/bar/project /Users/jfigueroa/go/src/foo/bar /Users/jfigueroa/go/src/foo /Users/jfigueroa/go/src /Users/jfigueroa/go /Users/jfigueroa /Users /]
INFO [lintersdb] Active 1 linters: [gocyclo]
INFO [loader] Go packages loading at mode load files took 776.866628ms
INFO [runner] worker.4 took 18.341µs
INFO [runner] worker.1 took 1.690227ms with stages: gocyclo: 1.683145ms
INFO [runner] worker.2 took 964ns
INFO [runner] worker.3 took 847ns
INFO [runner] Workers idle times: #1: 102.71µs, #2: 92.189µs, #4: 156.104µs
INFO [runner] processing took 5.998µs with stages: max_same_issues: 2.638µs, skip_dirs: 488ns, nolint: 409ns, cgo: 345ns, max_from_linter: 329ns, filename_unadjuster: 254ns, path_prettifier: 215ns, diff: 193ns, path_shortener: 161ns, skip_files: 160ns, source_code: 158ns, identifier_marker: 155ns, autogenerated_exclude: 151ns, max_per_file_from_linter: 104ns, uniq_by_line: 85ns, exclude-rules: 77ns, exclude: 76ns
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 11 samples, avg is 68.9MB, max is 68.9MB
INFO Execution took 914.612243ms

My .golangci.yml:

linters-settings:
  gocyclo:
    min-complexity: 5

Shouldn't the configs in gocyclo be the same flags as the original repo? top, over, average?

@unmultimedio
Copy link

Hello, all. Any updates here?

@ldez ldez added the stale No recent correspondence or work activity label Mar 24, 2021
@ldez ldez removed the bug Something isn't working label Apr 3, 2021
@stale stale bot removed the stale No recent correspondence or work activity label Apr 3, 2021
@ldez ldez added the stale No recent correspondence or work activity label Apr 3, 2021
@stale stale bot closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback required Requires additional feedback stale No recent correspondence or work activity
Projects
None yet
Development

No branches or pull requests

6 participants