diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 4da71559a..a69c8e289 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -17,6 +17,6 @@ jobs: go-version: '1.22' check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2 + uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0 with: - version: v1.64 + version: v2.0.1 diff --git a/.golangci.yml b/.golangci.yml index 400b428eb..b83e318b9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,26 +1,8 @@ ---- +version: "2" run: concurrency: 6 - timeout: 5m -issues: - exclude-rules: - # counterfeiter fakes are usually named 'fake_.go' - - path: fake_.*\.go - linters: - - gocritic - - golint - - dupl - - linters: - - goerr113 - text: do not define dynamic errors - - # Maximum issues count per one linter. Set to 0 to disable. Default is 50. - max-issues-per-linter: 0 - - # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. - max-same-issues: 0 linters: - disable-all: true + default: none enable: - asasalint - asciicheck @@ -39,7 +21,6 @@ linters: - errorlint - exhaustive - forcetypeassert - - gci - ginkgolinter - gocheckcompilerdirectives - gochecknoinits @@ -49,14 +30,10 @@ linters: - gocyclo - godot - godox - - gofmt - - gofumpt - goheader - - goimports - gomoddirectives - gomodguard - goprintffuncname - - gosimple - gosmopolitan - govet - grouper @@ -85,14 +62,11 @@ linters: - sloglint - sqlclosecheck - staticcheck - - stylecheck - tagalign - - tenv - testableexamples - testifylint - thelper - tparallel - - typecheck - unconvert - unparam - unused @@ -121,128 +95,164 @@ linters: # - varnamelen # - wrapcheck # - wsl -linters-settings: - godox: - keywords: - - BUG - - FIXME - - HACK - errcheck: - check-type-assertions: true - check-blank: true - gocritic: - enabled-checks: - - appendAssign - - appendCombine - - argOrder - - assignOp - - badCall - - badCond - - badLock - - badRegexp - - badSorting - - boolExprSimplify - - builtinShadow - - builtinShadowDecl - - captLocal - - caseOrder - - codegenComment - - commentFormatting - - commentedOutCode - - commentedOutImport - - defaultCaseOrder - - deferInLoop - - deferUnlambda - - deprecatedComment - - docStub - - dupArg - - dupBranchBody - - dupCase - - dupImport - - dupSubExpr - - dynamicFmtString - - elseif - - emptyDecl - - emptyFallthrough - - emptyStringTest - - equalFold - - evalOrder - - exitAfterDefer - - exposedSyncMutex - - externalErrorReassign - - filepathJoin - - flagDeref - - flagName - - hexLiteral - - httpNoBody - - hugeParam - - ifElseChain - - importShadow - - indexAlloc - - initClause - - mapKey - - methodExprCall - - nestingReduce - - newDeref - - nilValReturn - - octalLiteral - - offBy1 - - paramTypeCombine - - preferDecodeRune - - preferFilepathJoin - - preferFprint - - preferStringWriter - - preferWriteByte - - ptrToRefParam - - rangeExprCopy - - rangeValCopy - - redundantSprint - - regexpMust - - regexpPattern - - regexpSimplify - - returnAfterHttpError - - ruleguard - - singleCaseSwitch - - sliceClear - - sloppyLen - - sloppyReassign - - sloppyTypeAssert - - sortSlice - - sprintfQuotedString - - sqlQuery - - stringConcatSimplify - - stringXbytes - - stringsCompare - - switchTrue - - syncMapLoadAndDelete - - timeExprSimplify - - todoCommentWithoutDetail - - tooManyResultsChecker - - truncateCmp - - typeAssertChain - - typeDefFirst - - typeSwitchVar - - typeUnparen - - uncheckedInlineErr - - underef - - unlabelStmt - - unlambda - - unnamedResult - - unnecessaryBlock - - unnecessaryDefer - - unslice - - valSwap - - weakCond - - whyNoLint - - wrapperFunc - - yodaStyleExpr - nolintlint: - # Enable to ensure that nolint directives are all used. Default is true. - allow-unused: false - # Exclude following linters from requiring an explanation. Default is []. - allow-no-explanation: [] - # Enable to require an explanation of nonzero length after each nolint directive. Default is false. - # TODO(lint): Enforce explanations for `nolint` directives - require-explanation: false - # Enable to require nolint directives to mention the specific linter being suppressed. Default is false. - require-specific: true + settings: + errcheck: + check-type-assertions: true + check-blank: true + gocritic: + enabled-checks: + - appendCombine + - badLock + - badRegexp + - badSorting + - boolExprSimplify + - builtinShadow + - builtinShadowDecl + - commentedOutCode + - commentedOutImport + - deferInLoop + - deferUnlambda + - docStub + - dupImport + - dynamicFmtString + - emptyDecl + - emptyFallthrough + - emptyStringTest + - equalFold + - evalOrder + - exposedSyncMutex + - externalErrorReassign + - filepathJoin + - hexLiteral + - httpNoBody + - hugeParam + - importShadow + - indexAlloc + - initClause + - methodExprCall + - nestingReduce + - nilValReturn + - octalLiteral + - paramTypeCombine + - preferDecodeRune + - preferFilepathJoin + - preferFprint + - preferStringWriter + - preferWriteByte + - ptrToRefParam + - rangeExprCopy + - rangeValCopy + - redundantSprint + - regexpPattern + - regexpSimplify + - returnAfterHttpError + - ruleguard + - sliceClear + - sloppyReassign + - sortSlice + - sprintfQuotedString + - sqlQuery + - stringConcatSimplify + - stringXbytes + - stringsCompare + - syncMapLoadAndDelete + - timeExprSimplify + - todoCommentWithoutDetail + - tooManyResultsChecker + - truncateCmp + - typeAssertChain + - typeDefFirst + - typeUnparen + - uncheckedInlineErr + - unlabelStmt + - unnamedResult + - unnecessaryBlock + - unnecessaryDefer + - weakCond + - whyNoLint + - yodaStyleExpr + # - appendAssign + # - argOrder + # - assignOp + # - badCall + # - badCond + # - captLocal + # - caseOrder + # - codegenComment + # - commentFormatting + # - defaultCaseOrder + # - deprecatedComment + # - dupArg + # - dupBranchBody + # - dupCase + # - dupSubExpr + # - elseif + # - exitAfterDefer + # - flagDeref + # - flagName + # - ifElseChain + # - mapKey + # - newDeref + # - offBy1 + # - regexpMust + # - singleCaseSwitch + # - sloppyLen + # - sloppyTypeAssert + # - switchTrue + # - typeSwitchVar + # - underef + # - unlambda + # - unslice + # - valSwap + # - wrapperFunc + godox: + keywords: + - BUG + - FIXME + - HACK + nolintlint: + require-explanation: false + require-specific: true + allow-unused: false + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - dupl + - gocritic + - golint + # counterfeiter fakes are usually named 'fake_.go' + path: fake_.*\.go + - linters: + - err113 + text: do not define dynamic errors + paths: + - third_party$ + - builtin$ + - examples$ +issues: + # Maximum issues count per one linter. + # Set to 0 to disable. + # Default: 50 + max-issues-per-linter: 0 + # Maximum count of issues with the same text. + # Set to 0 to disable. + # Default: 3 + max-same-issues: 0 +formatters: + enable: + - gci + - gofmt + - gofumpt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/cmd/validate-rules/staging/validate.go b/cmd/validate-rules/staging/validate.go index 768f0d966..a99c5169c 100644 --- a/cmd/validate-rules/staging/validate.go +++ b/cmd/validate-rules/staging/validate.go @@ -54,7 +54,7 @@ func EnsureStagingDirectoriesExist(rules *config.RepositoryRules, baseBranch str // ensure all the mentioned directories exist for _, dir := range branchRule.Source.Dirs { _, directory := filepath.Split(dir) - if !(baseBranch == defaultBranch || (baseBranch != defaultBranch && baseBranch == branchRule.Source.Branch)) { + if baseBranch != defaultBranch && baseBranch != branchRule.Source.Branch { glog.Infof("Skipping branch %q for repository %q", branchRule.Source.Branch, directory) continue } @@ -65,7 +65,7 @@ func EnsureStagingDirectoriesExist(rules *config.RepositoryRules, baseBranch str } for _, dependency := range branchRule.Dependencies { - if !(baseBranch == defaultBranch || (baseBranch != defaultBranch && baseBranch == dependency.Branch)) { + if baseBranch != defaultBranch && baseBranch != dependency.Branch { glog.Infof("Skipping branch %q for dependency %q", dependency.Branch, dependency.Repository) continue } diff --git a/pkg/git/mainline.go b/pkg/git/mainline.go index 67c6a4799..492b211a2 100644 --- a/pkg/git/mainline.go +++ b/pkg/git/mainline.go @@ -45,11 +45,7 @@ func FirstParent(r *gogit.Repository, c *object.Commit) (*object.Commit, error) // of visited commits. func FirstParentList(r *gogit.Repository, c *object.Commit) ([]*object.Commit, error) { l := []*object.Commit{} - for { - if c == nil { - break - } - + for c != nil { l = append(l, c) // continue with first parent if there is one