-
Notifications
You must be signed in to change notification settings - Fork 43
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
Consume returned values implicitly, remove some nolint comments #410
Changes from 1 commit
4745782
f707deb
09cefde
290befe
a834b85
7ba6a23
a022c00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Lam Tran <[email protected]>
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import ( | |
"compress/gzip" | ||
"crypto/sha256" | ||
"encoding/hex" | ||
"errors" | ||
"fmt" | ||
"hash" | ||
"io" | ||
|
@@ -82,7 +83,7 @@ func Untar(dst string, src io.Reader) error { // dst, src order like io.Copy | |
tr := tar.NewReader(zSrc) | ||
for { | ||
header, err := tr.Next() | ||
if err == io.EOF { | ||
if errors.Is(err, io.EOF) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is something wrapping the io.EOF now or are you just expecting it to? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, my point is keeping the consistency when checking error at the present and also future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for letting me know your input, but I don't think we should call a more expensive function when we don't need it. First case you changed was in a unit test on code we wrote. We are testing an expected error. To reduce precision in a test is an anti-goal.. ex I would want to know if our code started wrapping errors. Making the assertion more flimsy allows that test to pass even if someone accidentally wrapped the error. Since we control the code we should know what we are doing and be able to tell if we made a mistake. The second place you changed the expression was unnecessary for a different reason. The reader api documents the result of EOF as a known behavior. We don't need to expect expect Even if func-e isn't particularly concerned about code size, memory size or perf, it is important to know what you are doing. In other libraries, we'd want to avoid bloat and performance loss for no reason. For example, you can see that using There are cases of style consistency where there could be subtle differences and choosing one over another is sensible. We totally do that. However, this is a behavior change and the choice adds surprise.. For example, I would suggest the otherwise should be true. If you use Hope this makes sense. One point that remains is you have added more scope to this PR after a request to reduce scope of it. This causes a day round trip and time to go over pros and cons. Changing the code policy of a project is something better to do when actively developing it vs a "drive by". For example, through fixing other issues, things that are priority to fix, the same time is spent and more value brought through discussions and whatnot. I would suggest to be somewhat empathetic to the project teams when doing style changes and not doing more things on each rev, as we end up in discussions like this which consume both of our time even if there is benefit personally, it starves other change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @codefromthecrypt |
||
break | ||
} else if err != nil { | ||
return err | ||
|
@@ -152,11 +153,11 @@ func TarGz(dst, src string) error { // dst, src order like io.Copy | |
if err != nil { | ||
return err | ||
} | ||
defer func() { _ = file.Close() }() | ||
defer file.Close() //nolint | ||
gzw := gzip.NewWriter(file) | ||
defer func() { _ = gzw.Close() }() | ||
defer gzw.Close() //nolint | ||
tw := tar.NewWriter(gzw) | ||
defer func() { _ = tw.Close() }() | ||
defer tw.Close() //nolint | ||
|
||
// Recurse through the path including all files and directories | ||
return fs.WalkDir(srcFS, basePath, func(path string, d os.DirEntry, err error) error { | ||
|
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.
similar... is something wrapping this error now?