From 798c328ab94a6174f3a2a4ff94c09ee6c26d677c Mon Sep 17 00:00:00 2001 From: Fabian Kammel Date: Mon, 23 Jun 2025 20:41:48 +0200 Subject: [PATCH 1/3] chore: migrate golangci lint to version 2 Signed-off-by: Fabian Kammel --- .golangci.yml | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c31980e0..064165f6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,16 +1,24 @@ +version: "2" linters: enable: - # golangci-lint defaults - # ref: https://golangci-lint.run/usage/linters/#enabled-by-default - - errcheck - - gosimple - - govet - - ineffassign - - staticcheck - - unused - # additional - - misspell - - gofmt - fast: true -run: - timeout: 5m \ No newline at end of file + - misspell + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ From 45c48d6d63d5dc4aa8a97339c89796f8e1e4172c Mon Sep 17 00:00:00 2001 From: Fabian Kammel Date: Mon, 23 Jun 2025 20:42:12 +0200 Subject: [PATCH 2/3] chore: fix golangci-lint findings Signed-off-by: Fabian Kammel --- commands/login.go | 2 +- commands/login_test.go | 2 +- policy/plugins/plugins_test.go | 2 +- policy/providerloader.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/login.go b/commands/login.go index 2f46ff91..c912821e 100644 --- a/commands/login.go +++ b/commands/login.go @@ -585,6 +585,6 @@ func isGitHubEnvironment() bool { // payloadFromCompactPkt extracts the payload from a compact PK Token which // is always the second part of the '.' separated string. func payloadFromCompactPkt(compactPkt []byte) []byte { - parts := bytes.SplitN(compactPkt, []byte("."), -1) + parts := bytes.Split(compactPkt, []byte(".")) return parts[1] } diff --git a/commands/login_test.go b/commands/login_test.go index aee2e1f6..be73fb05 100644 --- a/commands/login_test.go +++ b/commands/login_test.go @@ -322,7 +322,7 @@ func TestDetermineProvider(t *testing.T) { } else { require.NoError(t, err, "Unexpected error") require.True(t, provider != nil || chooser != nil, "Provider or chooser should never both be nil") - require.True(t, !(provider != nil && chooser != nil), "Provider or chooser should never both be non-nil") + require.False(t, provider != nil && chooser != nil, "Provider or chooser should never both be non-nil") if tt.wantIssuer != "" { require.NotNil(t, provider) diff --git a/policy/plugins/plugins_test.go b/policy/plugins/plugins_test.go index 3c606f56..800444f6 100644 --- a/policy/plugins/plugins_test.go +++ b/policy/plugins/plugins_test.go @@ -151,7 +151,7 @@ func TestPolicyPluginsWithMock(t *testing.T) { sub, _ := os.LookupEnv("OPKSSH_PLUGIN_SUB") aud, _ := os.LookupEnv("OPKSSH_PLUGIN_AUD") - if "/usr/bin/local/opk/policy-cmd" == name { + if name == "/usr/bin/local/opk/policy-cmd" { if len(arg) != 3 { return nil, fmt.Errorf("expected 3 arguments, got %d", len(arg)) diff --git a/policy/providerloader.go b/policy/providerloader.go index dbf66f14..26416a03 100644 --- a/policy/providerloader.go +++ b/policy/providerloader.go @@ -145,7 +145,7 @@ func NewProviderFileLoader() *ProvidersFileLoader { } func (o *ProvidersFileLoader) LoadProviderPolicy(path string) (*ProviderPolicy, error) { - content, err := o.FileLoader.LoadFileAtPath(path) + content, err := o.LoadFileAtPath(path) if err != nil { return nil, err } From 094ef8f82d9a3de1e5ce13528ae15317c295b689 Mon Sep 17 00:00:00 2001 From: Fabian Kammel Date: Mon, 23 Jun 2025 20:49:52 +0200 Subject: [PATCH 3/3] chore: up golangci-lint version to 2.1.0 Signed-off-by: Fabian Kammel --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 25ed9a31..bb2a4f1b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -23,7 +23,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v6 with: - version: v2.0.2 + version: v2.1.0 gotest: name: Run Tests