golangci-lint: enable more linters and address linting issues#191
golangci-lint: enable more linters and address linting issues#191rhatdan merged 12 commits intoopencontainers:mainfrom
Conversation
3ca8e8f to
6c393c4
Compare
|
I am ok with almost all of these, although I am not crazy about the if err := foobar(); err != nil Then Bottom line, I think err should be handled differently then other shadowed vars. But I am willing to live with the changes. LGTM |
6c393c4 to
4ef886f
Compare
Yes, I'm slightly on the fence on that one as well;
I don't think the linter itself has a config for this, but perhaps a string match exclusion would work (see https://golangci-lint.run/usage/false-positives/#exclude-issue-by-text) |
|
Tests are failing for go-fumpt? |
I probably need to rebase see #189 (comment) |
4ef886f to
d33149a
Compare
release notes: https://github.com/golangci/golangci-lint/releases/tag/v1.50.0 Signed-off-by: Sebastiaan van Stijn <[email protected]>
d33149a to
4dcd790
Compare
- The whitespace linter overlaps with gofumpt, so doesn't bring much.
- Enable govet's shadow check to check for shadowed variables.
- Add a short description to each linter.
pkg/pwalk/pwalk_test.go:78:8: shadow: declaration of "err" shadows declaration at line 69 (govet)
fi, err := os.CreateTemp(dir, "f-")
^
pkg/pwalkdir/pwalkdir_test.go:82:8: shadow: declaration of "err" shadows declaration at line 73 (govet)
fi, err := os.CreateTemp(dir, "f-")
^
Signed-off-by: Sebastiaan van Stijn <[email protected]>
go-selinux/selinux_linux.go:1089:2: var-naming: don't use underscores in Go names; var exclude_paths should be excludePaths
(revive)
go-selinux/selinux_linux.go:622:1: receiver-naming: receiver name l1 should be consistent with previous receiver name l for level
(revive)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
go-selinux/selinux.go:27:2: error-naming: error var InvalidLabel should have name of the form ErrFoo (revive) Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
By default, output is limited to 50 issues per linter, and 3 "same" issues. When enabling a new linter, this requires multiple runs of the linter to get a list of all issues. Let's assume we don't introduce "many" new issues at a time, and just show all the issues that were found. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
4dcd790 to
40803cc
Compare
|
Rebased, and tweaked the settings to ignore "err" for shadowing 👍 PTAL |
pkg/pwalk/pwalk.go:120:15: fieldalignment: struct with 24 pointer bytes could be 16 (govet)
type walkArgs struct {
^
pkg/pwalk/pwalk_test.go:136:18: fieldalignment: struct with 24 pointer bytes could be 16 (govet)
benchmarks := []struct {
^
pkg/pwalk/pwalk_test.go:146:15: fieldalignment: struct with 24 pointer bytes could be 16 (govet)
walkers := []struct {
^
pkg/pwalkdir/pwalkdir.go:113:15: fieldalignment: struct with 32 pointer bytes could be 24 (govet)
type walkArgs struct {
^
pkg/pwalkdir/pwalkdir_test.go:140:18: fieldalignment: struct with 24 pointer bytes could be 16 (govet)
benchmarks := []struct {
^
pkg/pwalkdir/pwalkdir_test.go:150:15: fieldalignment: struct with 24 pointer bytes could be 16 (govet)
walkers := []struct {
^
Signed-off-by: Sebastiaan van Stijn <[email protected]>
|
Oh! Had one more change staged in another branch; just pushed that one as well. |
go-selinux/selinux_linux.go:37:19: fieldalignment: struct with 40 pointer bytes could be 16 (govet)
type selinuxState struct {
^
go-selinux/selinux_linux.go:46:12: fieldalignment: struct with 16 pointer bytes could be 8 (govet)
type level struct {
^
go-selinux/selinux_linux.go:56:19: fieldalignment: struct with 88 pointer bytes could be 80 (govet)
type defaultSECtx struct {
^
go-selinux/selinux_linux_test.go:310:13: fieldalignment: struct with 64 pointer bytes could be 56 (govet)
tests := []struct {
^
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
2d54c3a to
ba8946a
Compare
rhatdan
left a comment
There was a problem hiding this comment.
LGTM
@kolyshkin @giuseppe @vrothberg PTAL
|
Nice work @thaJeztah |
(more coming after this, but I have ETOOMANYBRANCHES already)