-
Notifications
You must be signed in to change notification settings - Fork 1.2k
🏃 Update linter and lint fixes #773
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
Conversation
Hi @mcristina422. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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.
couple of questions, but mostly looks awesome.
Thanks so much!
@@ -86,7 +86,7 @@ func (e *Etcd) setProcessState() error { | |||
return err | |||
} | |||
|
|||
e.processState.StartMessage = internal.GetEtcdStartMessage(e.processState.URL) | |||
e.processState.HealthCheckEndpoint = "/health" |
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.
o_O
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.
StartMessage
is deprecated. So staticcheck is failing. I was iffy on this change too, we can add //nolint
to revert this change
@@ -36,7 +36,7 @@ var _ = Describe("runtime signal", func() { | |||
task := &Task{ | |||
ticker: time.NewTicker(time.Second * 2), | |||
} | |||
c := make(chan os.Signal) | |||
c := make(chan os.Signal, 1) |
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.
context on this one?
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.
SA1017: the channel used with signal.Notify should be buffered
https://staticcheck.io/docs/checks#SA1017
You can see elsewhere in the codebase
c := make(chan os.Signal, 2) |
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.
ah, prevents missing signals, ok.
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'm a big fan of most of the code changes... they make sense.
The exception is etcd.go
L89 change for which I don't at the moment understand the impact.
I'm most concern with the dropping of a number of enabled linters. Is the situation such that this PR would be too large to handle the update for all of them? or is it realized that these are dropped? or ? I think we need clear intention defined here.
.golangci.yml
Outdated
@@ -3,3 +3,5 @@ linters-settings: | |||
line-length: 170 | |||
dupl: | |||
threshold: 400 | |||
run: | |||
deadline: 5m |
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.
deadline
is deprecated... we should switch to timeout
details: golangci/golangci-lint#822
# --enable=gosec \ | ||
# --enable=maligned \ | ||
# --enable=safesql \ | ||
golangci-lint run ./pkg/... ./examples/... . |
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.
The following linters have been removed and are NOT enabled by default
--enable=misspell \
--enable=golint \
--enable=goconst \
--enable=unparam \
--enable=nakedret \
--enable=interfacer \
--enable=gocyclo \
--enable=lll \
--enable=dupl \
--enable=goimports \
Is this intended? If we plan to keep them... it would be great to add them to the .golangci.yml
file.
https://github.com/golangci/golangci-lint#enabled-by-default-linters
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.
No, this was not my intention. I misinterpreted how dropping the --disable-all
flag worked. I'll make sure to explicitly enable the same ones in the config file
/ok-to-test |
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.
@mcristina422 might I suggest that you change the one contested change around e.processState.HealthCheckEndpoint = "/health"
adding a //nolint:
there and we can have that debate separately?
The rest of this lgtm
@kensipe I've reverted the etcd change. Since In a follow up we can debate enabling more like |
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
@DirectXMan12 could we get a 2nd look on this? |
hack/check-everything.sh
Outdated
@@ -74,7 +74,7 @@ function fetch_go_tools { | |||
header_text "Checking for gometalinter.v2" | |||
if ! is_installed golangci-lint; then | |||
header_text "Installing golangci-lint" | |||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.21.0 | |||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.23.1 |
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.
long term maybe we introduce a tools.go to manage these dependencies with go modules - a few other tools do this.
@mcristina422 looks like it needs a rebase... lets see if we can get some attention on this after the rebase... thx |
@@ -235,7 +236,7 @@ var _ = Describe("Fake client", func() { | |||
Namespace: "ns2", | |||
} | |||
obj := &corev1.ConfigMap{} | |||
err = cl.Get(nil, namespacedName, obj) |
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.
Why this change is required?
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.
When running the linter with staticcheck enabled (not enforced by this PR) it fails with
SA1012: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (staticcheck)
@@ -152,7 +152,7 @@ var _ = Describe("controller", func() { | |||
By("Invoking Reconciling for an OwnedObject when it is updated") | |||
newReplicaset := replicaset.DeepCopy() | |||
newReplicaset.Labels = map[string]string{"foo": "bar"} | |||
newReplicaset, err = clientset.AppsV1().ReplicaSets("default").Update(newReplicaset) | |||
_, err = clientset.AppsV1().ReplicaSets("default").Update(newReplicaset) |
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.
👍 cool
@@ -24,29 +24,6 @@ go vet ${MOD_OPT} ./... | |||
|
|||
header_text "running golangci-lint" | |||
|
|||
golangci-lint run --disable-all \ |
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.
👍 cool
linters-settings: | ||
lll: | ||
line-length: 170 | ||
dupl: | ||
threshold: 400 | ||
|
||
run: | ||
timeout: 5m |
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.
👍 cool
c17d688
to
fd19c6a
Compare
@@ -1,5 +1,27 @@ | |||
linters: | |||
disable-all: true |
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'd suggest to flip these. Enable all linters and explicitly disable the others, so we know which ones we are disabling and folks can pick up the task of removing a disabled linter from this list if they wanted to.
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.
This is explicitly called out here because enable-all is deprecated
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.
Oh well, it seems a bit counter intuitive to me, but nothing major
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.
It shows great for me 👍
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mcristina422, vincepri The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This updates golangci-lint, moves the configuration all to
.golangci.yml
and then fixes the linter errors