diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 56dd399..fd0d6fc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -107,6 +107,6 @@ jobs: go-version-file: './go.mod' check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2 + uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 with: - version: v1.61 + version: v2.1 diff --git a/.golangci.yml b/.golangci.yml index 701deff..0955ce2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,32 +1,42 @@ --- +version: "2" +run: + issues-exit-code: 1 linters: enable: - asciicheck - - errcheck - errorlint - - gofmt - - goimports - - gosec - gocritic + - gosec - importas + - misspell - prealloc - revive - - misspell - - stylecheck + - staticcheck - unconvert - - unused - whitespace -output: - uniq-by-line: false + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ issues: - exclude-rules: - - path: _test\.go - linters: - - errcheck - - gosec - - revive max-issues-per-linter: 0 max-same-issues: 0 -run: - issues-exit-code: 1 - timeout: 10m + uniq-by-line: false +formatters: + enable: + - gofmt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/pkg/chart/chart_test.go b/pkg/chart/chart_test.go index 678bb80..901677c 100644 --- a/pkg/chart/chart_test.go +++ b/pkg/chart/chart_test.go @@ -28,19 +28,19 @@ import ( type fakeGit struct{} -func (g fakeGit) FileExistsOnBranch(file string, remote string, branch string) bool { +func (g fakeGit) FileExistsOnBranch(_ string, _ string, _ string) bool { return true } -func (g fakeGit) Show(file string, remote string, branch string) (string, error) { +func (g fakeGit) Show(_ string, _ string, _ string) (string, error) { return "", nil } -func (g fakeGit) MergeBase(commit1 string, commit2 string) (string, error) { +func (g fakeGit) MergeBase(_ string, _ string) (string, error) { return "HEAD", nil } -func (g fakeGit) ListChangedFilesInDirs(commit string, dirs ...string) ([]string, error) { +func (g fakeGit) ListChangedFilesInDirs(_ string, _ ...string) ([]string, error) { return []string{ "test_charts/foo/Chart.yaml", "test_charts/bar/Chart.yaml", @@ -55,15 +55,15 @@ func (g fakeGit) ListChangedFilesInDirs(commit string, dirs ...string) ([]string }, nil } -func (g fakeGit) AddWorktree(path string, ref string) error { +func (g fakeGit) AddWorktree(_ string, _ string) error { return nil } -func (g fakeGit) RemoveWorktree(path string) error { +func (g fakeGit) RemoveWorktree(_ string) error { return nil } -func (g fakeGit) GetURLForRemote(remote string) (string, error) { +func (g fakeGit) GetURLForRemote(_ string) (string, error) { return "git@github.com/helm/chart-testing", nil } @@ -71,13 +71,13 @@ func (g fakeGit) ValidateRepository() error { return nil } -func (g fakeGit) BranchExists(branch string) bool { +func (g fakeGit) BranchExists(_ string) bool { return true } type fakeAccountValidator struct{} -func (v fakeAccountValidator) Validate(repoDomain string, account string) error { +func (v fakeAccountValidator) Validate(_ string, account string) error { if strings.HasPrefix(account, "valid") { return nil } @@ -101,23 +101,23 @@ type fakeHelm struct { mock.Mock } -func (h *fakeHelm) AddRepo(name, url string, extraArgs []string) error { return nil } -func (h *fakeHelm) BuildDependencies(chart string) error { return nil } +func (h *fakeHelm) AddRepo(_, _ string, _ []string) error { return nil } +func (h *fakeHelm) BuildDependencies(_ string) error { return nil } func (h *fakeHelm) BuildDependenciesWithArgs(chart string, extraArgs []string) error { h.Called(chart, extraArgs) return nil } -func (h *fakeHelm) LintWithValues(chart string, valuesFile string) error { return nil } -func (h *fakeHelm) InstallWithValues(chart string, valuesFile string, namespace string, release string) error { +func (h *fakeHelm) LintWithValues(_ string, _ string) error { return nil } +func (h *fakeHelm) InstallWithValues(_ string, _ string, _ string, _ string) error { return nil } -func (h *fakeHelm) Upgrade(chart string, namespace string, release string) error { +func (h *fakeHelm) Upgrade(_ string, _ string, _ string) error { return nil } -func (h *fakeHelm) Test(namespace string, release string) error { +func (h *fakeHelm) Test(_ string, _ string) error { return nil } -func (h *fakeHelm) DeleteRelease(namespace string, release string) {} +func (h *fakeHelm) DeleteRelease(_ string, _ string) {} func (h *fakeHelm) Version() (string, error) { return "v3.0.0", nil diff --git a/pkg/tool/account.go b/pkg/tool/account.go index 26de6f1..1de8194 100644 --- a/pkg/tool/account.go +++ b/pkg/tool/account.go @@ -43,7 +43,7 @@ func (v AccountValidator) Validate(repoURL string, account string) error { func parseOutGitRepoDomain(repoURL string) (string, error) { // This works for GitHub, Bitbucket, and Gitlab submatch := repoDomainPattern.FindStringSubmatch(repoURL) - if submatch == nil || len(submatch) < 2 { + if len(submatch) < 2 { return "", fmt.Errorf("could not parse git repository domain for %q", repoURL) } return submatch[1], nil