version: "2" run: modules-download-mode: readonly # Unlimited so a failing run lists every issue; the defaults keep a # truncated sample whose members vary between runs. issues: max-issues-per-linter: 0 max-same-issues: 0 linters: default: none enable: - asasalint - asciicheck - bidichk - bodyclose - contextcheck - copyloopvar - depguard - dupword - errcheck - errorlint - exptostd - fatcontext - forbidigo - forcetypeassert - gocheckcompilerdirectives - gochecksumtype - gocritic - gomoddirectives - govet - ineffassign - makezero - mirror - misspell - modernize - nilerr - nilnesserr - nolintlint - nonamedreturns - nosprintfhostport - reassign - staticcheck - testifylint - unconvert - unparam - unused - usetesting - thelper - tparallel exclusions: presets: - comments - common-false-positives - legacy - std-error-handling rules: - path: _test\.go linters: - dupword - forbidigo - path-except: internal/commands/ linters: - forbidigo text: "stdout and stderr output" # TODO: surfaced by staticcheck in golangci-lint 2.13.x; drop these once # the deprecated fields are migrated and the token cache nil check is fixed. - path: (internal/api/milestone|internal/cmdutils/cmdutils|internal/commands/issue/create/issue_create_test|internal/commands/issue/create/issue_create_attach_test|internal/commands/mr/create/mr_create_test|internal/commands/mr/create/mr_create_attach_test)\.go linters: - staticcheck text: "SA1019" - path: internal/commands/cluster/agent/token_cache/list/list\.go linters: - staticcheck text: "SA4023" settings: forbidigo: forbid: - pattern: ^json\.Marshal(Indent)?$ msg: "Use IOStreams.PrintJSON for stdout output. For non-stdout serialization (request bodies, disk, protocols), add //nolint:forbidigo with a reason." - pattern: ^json\.NewEncoder$ msg: "Use IOStreams.PrintJSON for stdout output. For non-stdout serialization (request bodies, disk, protocols), add //nolint:forbidigo with a reason." - pattern: ^fmt\.F(print|printf|println|scan|scanf|scanln)$ msg: "Use IOStreams LogInfo, LogInfof, Error, and Errorf for stdout and stderr output." gocritic: enabled-tags: - diagnostic - style disabled-checks: # Wants named results, which nonamedreturns forbids. - unnamedResult # Narrower restatement of govet's shadow check, disabled below. - importShadow # Duplicates nolintlint's require-explanation. - whyNoLint # Purely cosmetic parameter grouping. - paramTypeCombine govet: enable-all: true disable: - fieldalignment - shadow modernize: disable: - omitzero # TODO: new in golangci-lint 2.13.x; re-enable once the tree is cleaned up. - errorsastype - embedlit - reflecttypeassert staticcheck: checks: - all - -QF* - -ST1003 - -ST1008 - -ST1012 - -ST1016 - -ST1018 - -ST1023 depguard: rules: cmdutils-only-in-commands: files: - "**/*.go" - "!**/cmd/glab/*.go" - "!**/cmd/gen-docs/*.go" - "!**/internal/testing/cmdtest/*.go" - "!**/internal/cmdutils/*_test.go" - "!**/internal/commands/*.go" - "!**/internal/commands/**/*.go" deny: - pkg: "gitlab.com/gitlab-org/cli/internal/cmdutils" desc: "internal/cmdutils should only be imported from packages under internal/commands/" no-testing-in-production: files: - "!$test" deny: - pkg: "gitlab.com/gitlab-org/cli/internal/testing/**" desc: "Testing utilities should only be used in test files" usetesting: context-background: true context-todo: true os-chdir: true os-mkdir-temp: true os-setenv: true os-create-temp: true os-temp-dir: true formatters: enable: - gci - gofumpt - goimports settings: gci: sections: - standard - default - prefix(gitlab.com/gitlab-org/api) - localmodule