Skip to content
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

Generated files inconsistently skipped #86

Closed
alecthomas opened this issue Jun 11, 2018 · 10 comments
Closed

Generated files inconsistently skipped #86

alecthomas opened this issue Jun 11, 2018 · 10 comments
Labels
bug Something isn't working

Comments

@alecthomas
Copy link
Contributor

alecthomas commented Jun 11, 2018

This is a weird one. Most generated files seem to be correctly skipped, but one doesn't:

$ golangci-lint run --fast
mocks/ec2api.go:304:22: method AssignPrivateIpAddresses should be AssignPrivateIPAddresses (golint)
mocks/ec2api.go:312:35: method AssignPrivateIpAddresses should be AssignPrivateIPAddresses (golint)
mocks/ec2api.go:317:22: method AssignPrivateIpAddressesRequest should be AssignPrivateIPAddressesRequest (golint)
...
$ head -1 mocks/ec2api.go
// Code generated by MockGen. DO NOT EDIT.
$ head -1 mocks/iamapi.go
// Code generated by MockGen. DO NOT EDIT.

If I delete mocks/ec2api.go, there are no lint errors.

@jirfag
Copy link
Member

jirfag commented Jun 12, 2018

Do you use the latest version of golangci-lint?

@jirfag jirfag added the bug Something isn't working label Jun 12, 2018
@alecthomas
Copy link
Contributor Author

Yep:

$ go get -v -u github.com/golangci/golangci-lint/cmd/golangci-lint
github.com/golangci/golangci-lint (download)
$ golangci-lint run --no-config --enable-all --fast --exclude-use-default=false --print-issued-lines=false
mocks/ec2api.go:304:22: method AssignPrivateIpAddresses should be AssignPrivateIPAddresses (golint)
mocks/ec2api.go:312:35: method AssignPrivateIpAddresses should be AssignPrivateIPAddresses (golint)
...

The config is the same as in #87.

@jirfag
Copy link
Member

jirfag commented Jun 12, 2018

run with -v option, please

@alecthomas
Copy link
Contributor Author

INFO[0000] Active 8 linters: [dupl goconst gocyclo gofmt goimports golint govet ineffassign]
INFO[0000] Skipped dirs: [.git pkg/awsenv/testdata vendor]
INFO[0000] Paths resolving took 9.073384ms: [cmd/sqm cmd/sqm/env cmd/sqm/service internal/registry mocks pkg/awsenv pkg/awsenv/iampolicy pkg/k8senv pkg/provision pkg/provision/database pkg/provision/iam pkg/provision/service server]
INFO[0000] worker.2 took 12.638351ms with stages: goconst: 12.395855ms
INFO[0000] worker.1 took 27.141672ms with stages: gocyclo: 27.109928ms
INFO[0000] worker.3 took 539.131379ms with stages: gofmt: 539.005183ms
INFO[0000] worker.8 took 665.664661ms with stages: golint: 665.636616ms
cmd/sqm/service/service_cmd.go:14:5: exported var ServiceCmd should have comment or be unexported (golint)
internal/registry/client.go:14:2: exported const RegistryServiceName should have comment (or a comment on this block) or be unexported (golint)
mocks/ec2api.go:304:22: method AssignPrivateIpAddresses should be AssignPrivateIPAddresses (golint)
mocks/ec2api.go:312:35: method AssignPrivateIpAddresses should be AssignPrivateIPAddresses (golint)
mocks/ec2api.go:317:22: method AssignPrivateIpAddressesRequest should be AssignPrivateIPAddressesRequest (golint)
mocks/ec2api.go:325:35: method AssignPrivateIpAddressesRequest should be AssignPrivateIPAddressesRequest (golint)
mocks/ec2api.go:330:22: method AssignPrivateIpAddressesWithContext should be AssignPrivateIPAddressesWithContext (golint)
mocks/ec2api.go:342:35: method AssignPrivateIpAddressesWithContext should be AssignPrivateIPAddressesWithContext (golint)
mocks/ec2api.go:2108:22: method CreateNetworkAcl should be CreateNetworkACL (golint)
mocks/ec2api.go:2116:35: method CreateNetworkAcl should be CreateNetworkACL (golint)
mocks/ec2api.go:2121:22: method CreateNetworkAclEntry should be CreateNetworkACLEntry (golint)
mocks/ec2api.go:2129:35: method CreateNetworkAclEntry should be CreateNetworkACLEntry (golint)
mocks/ec2api.go:2134:22: method CreateNetworkAclEntryRequest should be CreateNetworkACLEntryRequest (golint)
mocks/ec2api.go:2142:35: method CreateNetworkAclEntryRequest should be CreateNetworkACLEntryRequest (golint)
mocks/ec2api.go:2147:22: method CreateNetworkAclEntryWithContext should be CreateNetworkACLEntryWithContext (golint)
mocks/ec2api.go:2159:35: method CreateNetworkAclEntryWithContext should be CreateNetworkACLEntryWithContext (golint)
mocks/ec2api.go:2165:22: method CreateNetworkAclRequest should be CreateNetworkACLRequest (golint)
mocks/ec2api.go:2173:35: method CreateNetworkAclRequest should be CreateNetworkACLRequest (golint)
mocks/ec2api.go:2178:22: method CreateNetworkAclWithContext should be CreateNetworkACLWithContext (golint)
mocks/ec2api.go:2190:35: method CreateNetworkAclWithContext should be CreateNetworkACLWithContext (golint)
mocks/ec2api.go:3560:22: method DeleteNetworkAcl should be DeleteNetworkACL (golint)
mocks/ec2api.go:3568:35: method DeleteNetworkAcl should be DeleteNetworkACL (golint)
mocks/ec2api.go:3573:22: method DeleteNetworkAclEntry should be DeleteNetworkACLEntry (golint)
mocks/ec2api.go:3581:35: method DeleteNetworkAclEntry should be DeleteNetworkACLEntry (golint)
mocks/ec2api.go:3586:22: method DeleteNetworkAclEntryRequest should be DeleteNetworkACLEntryRequest (golint)
mocks/ec2api.go:3594:35: method DeleteNetworkAclEntryRequest should be DeleteNetworkACLEntryRequest (golint)
mocks/ec2api.go:3599:22: method DeleteNetworkAclEntryWithContext should be DeleteNetworkACLEntryWithContext (golint)
mocks/ec2api.go:3611:35: method DeleteNetworkAclEntryWithContext should be DeleteNetworkACLEntryWithContext (golint)
mocks/ec2api.go:3617:22: method DeleteNetworkAclRequest should be DeleteNetworkACLRequest (golint)
mocks/ec2api.go:3625:35: method DeleteNetworkAclRequest should be DeleteNetworkACLRequest (golint)
mocks/ec2api.go:3630:22: method DeleteNetworkAclWithContext should be DeleteNetworkACLWithContext (golint)
mocks/ec2api.go:3642:35: method DeleteNetworkAclWithContext should be DeleteNetworkACLWithContext (golint)
mocks/ec2api.go:4616:22: method DescribeAggregateIdFormat should be DescribeAggregateIDFormat (golint)
mocks/ec2api.go:4624:35: method DescribeAggregateIdFormat should be DescribeAggregateIDFormat (golint)
mocks/ec2api.go:4629:22: method DescribeAggregateIdFormatRequest should be DescribeAggregateIDFormatRequest (golint)
mocks/ec2api.go:4637:35: method DescribeAggregateIdFormatRequest should be DescribeAggregateIDFormatRequest (golint)
mocks/ec2api.go:4642:22: method DescribeAggregateIdFormatWithContext should be DescribeAggregateIDFormatWithContext (golint)
mocks/ec2api.go:4654:35: method DescribeAggregateIdFormatWithContext should be DescribeAggregateIDFormatWithContext (golint)
mocks/ec2api.go:5496:22: method DescribeIdFormat should be DescribeIDFormat (golint)
mocks/ec2api.go:5504:35: method DescribeIdFormat should be DescribeIDFormat (golint)
mocks/ec2api.go:5509:22: method DescribeIdFormatRequest should be DescribeIDFormatRequest (golint)
mocks/ec2api.go:5517:35: method DescribeIdFormatRequest should be DescribeIDFormatRequest (golint)
mocks/ec2api.go:5522:22: method DescribeIdFormatWithContext should be DescribeIDFormatWithContext (golint)
mocks/ec2api.go:5534:35: method DescribeIdFormatWithContext should be DescribeIDFormatWithContext (golint)
mocks/ec2api.go:5540:22: method DescribeIdentityIdFormat should be DescribeIdentityIDFormat (golint)
mocks/ec2api.go:5548:35: method DescribeIdentityIdFormat should be DescribeIdentityIDFormat (golint)
mocks/ec2api.go:5553:22: method DescribeIdentityIdFormatRequest should be DescribeIdentityIDFormatRequest (golint)
mocks/ec2api.go:5561:35: method DescribeIdentityIdFormatRequest should be DescribeIdentityIDFormatRequest (golint)
mocks/ec2api.go:5566:22: method DescribeIdentityIdFormatWithContext should be DescribeIdentityIDFormatWithContext (golint)
mocks/ec2api.go:5578:35: method DescribeIdentityIdFormatWithContext should be DescribeIdentityIDFormatWithContext (golint)
INFO[0000] worker.4 took 702.821191ms with stages: govet: 702.774887ms
INFO[0001] worker.5 took 900.21474ms with stages: dupl: 900.059629ms
INFO[0001] worker.6 took 914.431381ms with stages: ineffassign: 914.272168ms
INFO[0001] worker.7 took 1.402011808s with stages: goimports: 1.401956269s
INFO[0001] Workers idle times: #1: 1.37468881s, #2: 1.389209874s, #3: 862.821252ms, #4: 699.209343ms, #5: 501.795176ms, #6: 487.515665ms, #8: 736.384082ms
INFO[0001] 54/104 issues from linter golint were hidden, use --max-issues-per-linter
INFO[0001] processing took 664.053µs with stages: nolint: 481.642µs, max_from_linter: 59.776µs, max_same_issues: 42.253µs, uniq_by_line: 27.461µs, autogenerated_exclude: 19.174µs, path_prettifier: 17.784µs, max_per_file_from_linter: 9.538µs, cgo: 5.732µs, diff: 283ns, skip_files: 220ns, exclude: 190ns
INFO[0001] Found 50 issues
INFO[0001] Extracting issued lines took 0s
INFO[0001] Memory: 16 samples, avg is 278.1MB, max is 384.0MB
INFO[0001] Execution took 1.50547928s

@alecthomas
Copy link
Contributor Author

I reran it with --max-issues-per-linter=5000. Still only messages from that one file.

jirfag added a commit that referenced this issue Jun 12, 2018
Write debug logs for autogen excluding for #86
@jirfag
Copy link
Member

jirfag commented Jun 12, 2018

I added debug logs in #89.
Run

go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
GL_DEBUG=autogen_exclude golangci-lint run --no-config --enable-all --fast --exclude-use-default=false --print-issued-lines=false mocks/ec2api.go

It should print a lot of debug logs like this:

INFO[0000] Active 8 linters: [dupl goconst gocyclo gofmt goimports golint govet ineffassign]
INFO[0000] Paths resolving took 9.626347ms: [test/testdata/autogenerated]
INFO[0000] worker.2 took 7.188666ms with stages: goimports: 7.132209ms, goconst: 33.716µs
INFO[0000] worker.3 took 804.144µs with stages: ineffassign: 706.18µs, gocyclo: 57.581µs
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/autogenerated.go": astcache file is {F:0xc4200fcb80 Fset:0xc4200dc640 Name:test/testdata/autogenerated/autogenerated.go Err:<nil>}
INFO[0000] worker.4 took 14.934228ms with stages: govet: 10.527598ms
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/autogenerated.go": search comments until EOF pos 61 (test/testdata/autogenerated/autogenerated.go:4:12)
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/autogenerated.go": pos=1, filePos=test/testdata/autogenerated/autogenerated.go:1:1: comment "Code generated by ... DO NOT EDIT.\n": it's allowed
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/autogenerated.go": got 1 allowed comments
DEBU[0000] autogen_exclude: doc contains marker "code generated": file is generated
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/autogenerated.go" is generated: true
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/do_not_edit.go": astcache file is {F:0xc4200fcc00 Fset:0xc4200dc640 Name:test/testdata/autogenerated/do_not_edit.go Err:<nil>}
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/do_not_edit.go": search comments until EOF pos 137 (test/testdata/autogenerated/do_not_edit.go:4:21)
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/do_not_edit.go": pos=63, filePos=test/testdata/autogenerated/do_not_edit.go:1:1: comment "DO NOT EDIT Code generated by something\n": it's allowed
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/do_not_edit.go": got 1 allowed comments
DEBU[0000] autogen_exclude: doc contains marker "code generated": file is generated
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/do_not_edit.go" is generated: true
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/go_bindata.go": astcache file is {F:0xc4200fcc80 Fset:0xc4200dc640 Name:test/testdata/autogenerated/go_bindata.go Err:<nil>}
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/go_bindata.go": search comments until EOF pos 241 (test/testdata/autogenerated/go_bindata.go:8:11)
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/go_bindata.go": pos=139, filePos=test/testdata/autogenerated/go_bindata.go:1:1: comment "Code generated by go-bindata.\nsources:\nbar.baz\nx/y.z\nDO NOT EDIT!\n": it's allowed
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/go_bindata.go": got 1 allowed comments
DEBU[0000] autogen_exclude: doc contains marker "code generated": file is generated
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/go_bindata.go" is generated: true
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/mockgen.go": astcache file is {F:0xc4200fcd00 Fset:0xc4200dc640 Name:test/testdata/autogenerated/mockgen.go Err:<nil>}
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/mockgen.go": search comments until EOF pos 366 (test/testdata/autogenerated/mockgen.go:6:22)
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/mockgen.go": pos=243, filePos=test/testdata/autogenerated/mockgen.go:1:1: comment "Code generated by MockGen. DO NOT EDIT.\nSource: ./app/analyze/executors/executor.go\n": it's allowed
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/mockgen.go": got 1 allowed comments
DEBU[0000] autogen_exclude: doc contains marker "code generated": file is generated
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/mockgen.go" is generated: true
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/protoc_gen_foo.go": astcache file is {F:0xc4200fcd80 Fset:0xc4200dc640 Name:test/testdata/autogenerated/protoc_gen_foo.go Err:<nil>}
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/protoc_gen_foo.go": search comments until EOF pos 463 (test/testdata/autogenerated/protoc_gen_foo.go:6:10)
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/protoc_gen_foo.go": pos=368, filePos=test/testdata/autogenerated/protoc_gen_foo.go:1:1: comment "Code generated by protoc-gen-foo\nsource: bar.proto\nDO NOT EDIT!!!\n": it's allowed
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/protoc_gen_foo.go": got 1 allowed comments
DEBU[0000] autogen_exclude: doc contains marker "code generated": file is generated
DEBU[0000] autogen_exclude: file "test/testdata/autogenerated/protoc_gen_foo.go" is generated: true
INFO[0000] worker.1 took 15.922328ms with stages: dupl: 9.67187ms, golint: 5.758656ms, gofmt: 448.211µs
INFO[0000] Workers idle times: #2: 9.466087ms, #3: 9.435043ms, #4: 7.294498ms
INFO[0000] processing took 8.117925ms with stages: autogenerated_exclude: 8.069002ms, path_prettifier: 31.216µs, cgo: 7.661µs, nolint: 2.436µs, max_same_issues: 2.125µs, exclude: 1.287µs, uniq_by_line: 1.231µs, max_per_file_from_linter: 940ns, skip_files: 732ns, max_from_linter: 701ns, diff: 594ns
Congrats! No issues were found.
INFO[0000] Extracting issued lines took 0s
INFO[0000] Memory: 1 samples, avg is 14.2MB, max is 14.2MB
INFO[0000] Execution took 90.226414ms

@alecthomas
Copy link
Contributor Author

You've fixed it!

$ golangci-lint run --no-config --enable-all --fast --exclude-use-default=false --print-issued-lines=false mocks/ec2api.go
Congrats! No issues were found.

Previous version:

$ ~/.go/bin/golangci-lint run --no-config --enable-all --fast --exclude-use-default=false --print-issued-lines=false mocks/ec2api.go

mocks/ec2api.go:304:22: method AssignPrivateIpAddresses should be AssignPrivateIPAddresses (golint)
mocks/ec2api.go:312:35: method AssignPrivateIpAddresses should be AssignPrivateIPAddresses (golint)
...

Also the debug logging is excellent, thank you.

@alecthomas
Copy link
Contributor Author

Though you did say it was just a logging change, so is it expected to have fixed it?

@alecthomas alecthomas reopened this Jun 12, 2018
@jirfag
Copy link
Member

jirfag commented Jun 12, 2018

It was just a logging change, fix of mockgen detection was a day ago, I think that despite you did go get -v -u github.com/golangci/golangci-lint/cmd/golangci-lint you somehow used another, old binary.

It's fine that it works :)

@jirfag jirfag closed this as completed Jun 12, 2018
@alecthomas
Copy link
Contributor Author

👍

Really weird :(

Sorry about the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants