-
Notifications
You must be signed in to change notification settings - Fork 371
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
lint: enable errcheck and fix some issues #327
lint: enable errcheck and fix some issues #327
Conversation
* add .errcheck-excluded.txt to disable some function calls * related to kubernetes-sigs#325
16da45d
to
c066971
Compare
I had added |
Codecov Report
@@ Coverage Diff @@
## master #327 +/- ##
==========================================
- Coverage 57.3% 56.89% -0.42%
==========================================
Files 19 19
Lines 904 907 +3
==========================================
- Hits 518 516 -2
- Misses 335 338 +3
- Partials 51 53 +2
Continue to review full report at Codecov.
|
cmd/validate-krew-manifest/main.go
Outdated
flag.Set("logtostderr", "true") // Set glog default to stderr | ||
// Set glog default to stderr | ||
if err := flag.Set("logtostderr", "true"); err != nil { | ||
glog.Fatal(err) |
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 think it would be good to use fmt.Printf + os.Exit(1) here, as glog is currently not initialized probably.
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.
updated as suggested.
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.
Looking at this a little more, I do not understand why some errors are not reported. For example, in pkg/receiptsmigration/migration_test.go:66 there is a Setenv
call which returns an unhandled error that is not reported. On the other hand, the unhandled MkdirAll
error in line 72 is reported. So what is the logic behind reporting some but not all errors?
.errcheck-excluded.txt
Outdated
@@ -0,0 +1,2 @@ | |||
os.MkdirAll |
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.
Would it also be possible to explicitly ignore errors in the exact locations where we want to ignore errors. Like so:
_ = os.MkdirAll(...)
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.
definitely. Then we shouldn't have this file for the sake of being explicit all the time.
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.
yes, it's possible. For being explicit, I dropped this file.
@corneliusweig updated and seems so. Thanks! |
.errcheck-excluded.txt
Outdated
@@ -0,0 +1,2 @@ | |||
os.MkdirAll |
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.
since it's just 2 lines or possibly even 1, let's just drop this file if possible and call errcheck with --flags. it's kinda annoying to have an extra file in repo root just for this.
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.
yes, dropped. Will push soon.
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.
pushed.
It seems a bug from golangci-lint. Even if errcheck reports it, golangci-lint doesn't report it. Reported at golangci/golangci-lint#657 |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahmetb, ferhatelmas 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 |
.errcheck-excluded.txt
to disable some function calls as an example