-
Notifications
You must be signed in to change notification settings - Fork 704
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
Update golangci-lint/goimports configuration #4945
Update golangci-lint/goimports configuration #4945
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read through all changes and all looks good. I was able to find few more files that have more than three groups though:
pkg/controller/association/reconciler.go
pkg/controller/association/conf.go
pkg/controller/association/resources_test.go
pkg/controller/association/controller/beat_es.go
pkg/controller/enterprisesearch/pod_test.go
pkg/controller/kibana/pod_test.go
pkg/controller/kibana/driver_test.go
pkg/controller/common/license/verifier_test.go
pkg/controller/common/keystore/resources_test.go
pkg/controller/elasticsearch/remotecluster/elasticsearch_test.go
pkg/controller/elasticsearch/user/associated_test.go
pkg/controller/elasticsearch/user/user_provided_test.go
pkg/controller/elasticsearch/sset/list_test.go
pkg/controller/remoteca/watches.go
pkg/dev/portforward/pod_forwarder_test.go
I found them using the following invocation and while I have little confidence that it's the best way, maybe we should follow up with including this into make lint
? With that and goimports
we should cover all cases and keep all the imports neat from now on.
$ find . -name "*\.go" | xargs -I 'file' bash -c 'echo -n "file - " && sed -E -n "/import \(/,/\)/P" file | grep -c "^$"' | grep -v '\(0\|1\|2\)' | cut -f 1 -d " "
If we go for this new three section import block we should also update the contributing guideline accordingly. |
5dcc33d
to
6c21708
Compare
Ok, I've updated the contribution document, as well as fixed the additional files. How would yall like to handle detecting imports that are not valid? Add something to the makefile such as the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! As for adding the check I'd be fine both ways, curious what others think too.
Why do we need another check? Or put differently why did goimports not catch all cases? |
Because when more groups are present it thinks that it's on purpose and fixes them only partially. |
From doing some investigation, goimports doesn't handle things perfectly as we'd want it to. See golang/go#20818 Taking one of the files you noted earlier that wasn't "fixed", from the master branch, and note it isn't shown that it would be "fixed" by goimports (that is, the 2x 3rd party groupings aren't combined.
But, as noted in the golang issue above, there is a fork of goimports that seems to handle this properly
Is this fork a path we want to go down, or simply work under the assumption that PR reviews + golangci-lint will catch the vast majority of these improper imports? |
6c21708
to
f7e837f
Compare
@david-kow @pebrc any thoughts on the above question? Should we just leave as-is, and merge? lmk, thanks. |
I'd be fine both with merging as is and with adding the script to verify group count. |
f7e837f
to
7469552
Compare
… a local prefix in imports
Add back linter hints
Add back more linter hints
Update additional files to group import groups properly
7469552
to
4743b16
Compare
Same. |
* Update goimports settings to consider github.com/elastic/cloud-on-k8s a local prefix in imports * remove comment in golangci.yml * Fix imports Add back linter hints * Fix more imports Add back more linter hints * Update verbiage for ccontributing guidelines Update additional files to group import groups properly * Fix mis-aligned imports * Fix additional bad import statements
Update goimports settings to consider github.com/elastic/cloud-on-k8s a local prefix in imports section.
This standardizes having