fix linting issues for golangci-lint v2#187
Conversation
|
|
||
| func (w syncFileCloser) Close() error { | ||
| err := w.File.Sync() | ||
| err := w.Sync() |
There was a problem hiding this comment.
Still a bit on the fence on this one. Yes, it's correct that you can access the embedded field directly, but I think in this case it's better to be explicit. I had a quick peek at the new configuration options, and it looks like we can exclude this "quickfix". From the docs, I think there's various other ones that are disabled by default that we could (should) enable; https://golangci-lint.run/usage/linters/#staticcheck
I'll update the config in the other PR, and drop the commit here.
Error: mountinfo/mounted_linux_test.go:282:6: QF1001: could apply De Morgan's law (staticcheck)
if !(tc.isNotExist && errors.Is(err, os.ErrNotExist)) {
^
Error: mountinfo/mounted_linux_test.go:353:8: QF1001: could apply De Morgan's law (staticcheck)
if !(tc.isNotExist && errors.Is(err, os.ErrNotExist)) {
^
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Error: capability/syscall_linux.go:144:2: QF1003: could use tagged switch on data.version (staticcheck)
if data.version == 1 {
^
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Error: user/user.go:447:16: ST1005: error strings should not be capitalized (staticcheck)
return nil, fmt.Errorf("Unable to find additional groups %v: %w", additionalGroups, err)
^
Error: user/user.go:471:17: ST1005: error strings should not be capitalized (staticcheck)
return nil, fmt.Errorf("Unable to find group %s: %w", ag, ErrNoGroupEntries)
^
Signed-off-by: Sebastiaan van Stijn <[email protected]>
5e37fa7 to
3c88fb3
Compare
|
Dropped the first commit; I'll bring this one in and rebase the other one. |
|
Ha! Yes, most of the changes seemed reasonable; I was slightly on the fence on the "apply De Morgan's law" changes in 8d553c0, but then again, either before and after would need a short comment (already in place) to outline the logic, so I took that one as "OK, let's make the linter happy". I didn't like the "use embedded struct directly". At least; not in this specific case (there's situations where it's OK, but this one was not one of them). |
We could suppress this linter, as using w.File.xxx makes it slightly more explicit, but probably fine as well.