Skip to content

chore: enable and fixes rules from gocritic - #246

Open
mmorel-35 wants to merge 9 commits into
moby:mainfrom
mmorel-35:gocritic
Open

chore: enable and fixes rules from gocritic#246
mmorel-35 wants to merge 9 commits into
moby:mainfrom
mmorel-35:gocritic

Conversation

@mmorel-35

Copy link
Copy Markdown

Enables all gocritic rules by default, then excludes the one non compliant then fix one rule per commit
Covers #245 gocritic part only

Comment thread .golangci.yml Outdated
Comment thread .golangci.yml Outdated
@kolyshkin

Copy link
Copy Markdown
Collaborator

Overall LGTM, left some nits.

@mmorel-35
mmorel-35 force-pushed the gocritic branch 2 times, most recently from 28b23df to 1f2af12 Compare August 18, 2026 05:27
Comment thread .golangci.yml Outdated

@kolyshkin kolyshkin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; @thaJeztah PTAL

@thaJeztah

Copy link
Copy Markdown
Member

Oh! You need to rebase, because go1.27 is not "stable", so GolangCi-lint needed updating

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a rebase (see above), but LGTM after the list is updated to the ones we actually hit; #246 (comment)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
@mmorel-35
mmorel-35 requested a review from thaJeztah September 4, 2026 09:36
Comment thread mount/mount_unix_test.go
Comment on lines +235 to +236
//nolint:errcheck // Ignore error in tests
Unmount(dir)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just explicitly ignore the error, then we don't need a nolint comment;

Suggested change
//nolint:errcheck // Ignore error in tests
Unmount(dir)
_ = Unmount(dir)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't think moving this to a utility is correct; it changes semantics because it now unmounts immediately? If we want to keep that behavior, then we could do something like;

var toUnMount []string

t.Cleanup(func() {
    for _ m := range toUnmount {
        _ = Unmount(m)
   }
})

(either t.Cleanup or defer, depending on go version supported, but I'd be fine bumping to a slightly newer version if needed)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly the utility of #253 could be used if it's modified to take a variadic strings.

Comment thread mount/mount_unix_test.go
Comment on lines +276 to +282

func mountTemporaryDirectory(t *testing.T, dir string) {
if err := Mount("tmpfs", dir, "tmpfs", ""); err != nil {
t.Fatal(err)
}
Unmount(dir) //nolint:errcheck // Ignore error in tests
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here; we can also defer the unmount explicitly ignore errors here as well;

_ = Unmount(dir) //nolint:errcheck // Ignore error in tests

If the defer / cleanup wasn't relevant to the test, we can just inline it without the cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants