From 2e8fbad64136e42783deb21b8d9466f88a447fdb Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 16 Jul 2025 07:51:04 +0000 Subject: [PATCH] Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (#705) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Change | Age | Confidence | |---|---|---|---| | [github.com/golangci/golangci-lint/cmd/golangci-lint](https://github.com/golangci/golangci-lint) | `v1.64.8` -> `v2.2.2` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgolangci%2fgolangci-lint%2fcmd%2fgolangci-lint/v2.2.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgolangci%2fgolangci-lint%2fcmd%2fgolangci-lint/v1.64.8/v2.2.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
golangci/golangci-lint (github.com/golangci/golangci-lint/cmd/golangci-lint) ### [`v2.2.2`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v222) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.2.1...v2.2.2) 1. Linters bug fixes - `noinlineerr`: from 1.0.3 to 1.0.4 2. Documentation - Improve debug keys documentation 3. Misc. - fix: panic close of closed channel - godot: add noinline value into the JSONSchema ### [`v2.2.1`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v221) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.2.0...v2.2.1) 1. Linters bug fixes - `varnamelen`: fix configuration ### [`v2.2.0`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v220) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.1.6...v2.2.0) 1. New linters - Add `arangolint` linter https://github.com/Crocmagnon/arangolint - Add `embeddedstructfieldcheck` linter https://github.com/manuelarte/embeddedstructfieldcheck - Add `noinlineerr` linter https://github.com/AlwxSin/noinlineerr - Add `swaggo` formatter https://github.com/golangci/swaggoswag 2. Linters new features or changes - `errcheck`: add `verbose` option - `funcorder`: from 0.2.1 to 0.5.0 (new option `alphabetical`) - `gomoddirectives`: from 0.6.1 to 0.7.0 (new option `ignore-forbidden`) - `iface`: from 1.3.1 to 1.4.0 (new option `unexported`) - `noctx`: from 0.1.0 to 0.3.3 (new report messages, and new rules related to `database/sql`) - `noctx`: from 0.3.3 to 0.3.4 (new SQL functions detection) - `revive`: from 1.9.0 to 1.10.0 (new rules: `time-date`, `unnecessary-format`, `use-fmt-print`) - `usestdlibvars`: from 1.28.0 to 1.29.0 (new option `time-date-month`) - `wsl`: deprecation - `wsl_v5`: from 4.7.0 to 5.0.0 (major version with new configuration) 3. Linters bug fixes - `dupword`: from 0.1.3 to 0.1.6 - `exptostd`: from 0.4.3 to 0.4.4 - `forbidigo`: from 1.6.0 to 2.1.0 - `gci`: consistently format the code - `go-spancheck`: from 0.6.4 to 0.6.5 - `goconst`: from 1.8.1 to 1.8.2 - `gosec`: from 2.22.3 to 2.22.4 - `gosec`: from 2.22.4 to 2.22.5 - `makezero`: from 1.2.0 to 2.0.1 - `misspell`: from 0.6.0 to 0.7.0 - `usetesting`: from 0.4.3 to 0.5.0 4. Misc. - exclusions: fix `path-expect` - formatters: write the input to `stdout` when using `stdin` and there are no changes - migration: improve the error message when trying to migrate a migrated config - `typecheck`: deduplicate errors - `typecheck`: stops the analysis after the first error - Deprecate `print-resources-usage` flag - Unique version per custom build 5. Documentation - Improves typecheck FAQ - Adds plugin systems recommendations - Add description for `linters.default` sets ### [`v2.1.6`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v216) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.1.5...v2.1.6) 1. Linters bug fixes - `godot`: from 1.5.0 to 1.5.1 - `musttag`: from 0.13.0 to 0.13.1 2. Documentation - Add note about golangci-lint v2 integration in VS Code ### [`v2.1.5`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v215) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.1.4...v2.1.5) Due to an error related to Snapcraft, some artifacts of the v2.1.4 release have not been published. This release contains the same things as v2.1.3. ### [`v2.1.4`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v214) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.1.3...v2.1.4) Due to an error related to Snapcraft, some artifacts of the v2.1.3 release have not been published. This release contains the same things as v2.1.3. ### [`v2.1.3`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v213) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.1.2...v2.1.3) 1. Linters bug fixes - `fatcontext`: from 0.7.2 to 0.8.0 2. Misc. - migration: fix `nakedret.max-func-lines: 0` - migration: fix order of `staticcheck` settings - fix: add `go.mod` hash to the cache salt - fix: use diagnostic position for related information position ### [`v2.1.2`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v212) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.1.1...v2.1.2) 1. Linters bug fixes - `exptostd`: from 0.4.2 to 0.4.3 - `gofumpt`: from 0.7.0 to 0.8.0 - `protogetter`: from 0.3.13 to 0.3.15 - `usetesting`: from 0.4.2 to 0.4.3 ### [`v2.1.1`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v211) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.1.0...v2.1.1) The release process of v2.1.0 failed due to a regression inside goreleaser. The binaries of v2.1.0 have been published, but not the other artifacts (AUR, Docker, etc.). ### [`v2.1.0`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v210) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.0.2...v2.1.0) 1. Enhancements - Add an option to display absolute paths (`--path-mode=abs`) - Add configuration path placeholder (`${config-path}`) - Add `warn-unused` option for `fmt` command - Colored diff for `fmt` command (`golangci-lint fmt --diff-colored`) 2. New linters - Add `funcorder` linter https://github.com/manuelarte/funcorder 3. Linters new features or changes - `go-errorlint`: from 1.7.1 to 1.8.0 (automatic error comparison and type assertion fixes) - โš ๏ธ `goconst`: `ignore-strings` is deprecated and replaced by `ignore-string-values` - `goconst`: from 1.7.1 to 1.8.1 (new options: `find-duplicates`, `eval-const-expressions`) - `govet`: add `httpmux` analyzer - `nilnesserr`: from 0.1.2 to 0.2.0 (detect more cases) - `paralleltest`: from 1.0.10 to 1.0.14 (checks only `_test.go` files) - `revive`: from 1.7.0 to 1.9.0 (support kebab case for setting names) - `sloglint`: from 0.9.0 to 0.11.0 (autofix, new option `msg-style`, suggest `slog.DiscardHandler`) - `wrapcheck`: from 2.10.0 to 2.11.0 (new option `report-internal-errors`) - `wsl`: from 4.6.0 to 4.7.0 (cgo files are always excluded) 4. Linters bug fixes - `fatcontext`: from 0.7.1 to 0.7.2 - `gocritic`: fix `importshadow` checker - `gosec`: from 2.22.2 to 2.22.3 - `ireturn`: from 0.3.1 to 0.4.0 - `loggercheck`: from 0.10.1 to 0.11.0 - `nakedret`: from 2.0.5 to 2.0.6 - `nonamedreturns`: from 1.0.5 to 1.0.6 - `protogetter`: from 0.3.12 to 0.3.13 - `testifylint`: from 1.6.0 to 1.6.1 - `unconvert`: update to HEAD 5. Misc. - Fixes memory leaks when using go1.(N) with golangci-lint built with go1.(N-X) - Adds `golangci-lint-fmt` pre-commit hook 6. Documentation - Improvements - Updates section about vscode integration ### [`v2.0.2`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v202) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.0.1...v2.0.2) 1. Misc. - Fixes flags parsing for formatters - Fixes the filepath used by the exclusion `source` option 2. Documentation - Adds a section about flags migration - Cleaning pages with v1 options ### [`v2.0.1`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v201) [Compare Source](https://github.com/golangci/golangci-lint/compare/v2.0.0...v2.0.1) 1. Linters/formatters bug fixes - `golines`: fix settings during linter load 2. Misc. - Validates the `version` field before the configuration - `forbidigo`: fix migration ### [`v2.0.0`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v200) [Compare Source](https://github.com/golangci/golangci-lint/compare/v1.64.8...v2.0.0) 1. Enhancements - ๐ŸŒŸ New `golangci-lint fmt` command with dedicated [formatter configuration](https://golangci-lint.run/welcome/quick-start/#formatting) - โ™ป๏ธ New `golangci-lint migrate` command to help migration from v1 to v2 (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/#command-migrate)) - โš ๏ธ New default values (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/)) - โš ๏ธ No exclusions by default (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/#issuesexclude-use-default)) - โš ๏ธ New default sort order (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/#outputsort-order)) - ๐ŸŒŸ New option `run.relative-path-mode` (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/#runrelative-path-mode)) - ๐ŸŒŸ New linters configuration (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/#linters)) - ๐ŸŒŸ New output format configuration (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/#output)) - ๐ŸŒŸ New `--fast-only` flag (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/#lintersfast)) - ๐ŸŒŸ New option `linters.exclusions.warn-unused` to log a warning if an exclusion rule is unused. 2. New linters/formatters - Add `golines` formatter https://github.com/segmentio/golines 3. Linters new features - โš ๏ธ Merge `staticcheck`, `stylecheck`, `gosimple` into one linter (`staticcheck`) (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/#lintersenablestylecheckgosimplestaticcheck)) - `go-critic`: from 0.12.0 to 0.13.0 - `gomodguard`: from 1.3.5 to 1.4.1 (block explicit indirect dependencies) - `nilnil`: from 1.0.1 to 1.1.0 (new option: `only-two`) - `perfsprint`: from 0.8.2 to 0.9.1 (checker name in the diagnostic message) - `staticcheck`: new `quickfix` set of rules - `testifylint`: from 1.5.2 to 1.6.0 (new options: `equal-values`, `suite-method-signature`, `require-string-msg`) - `wsl`: from 4.5.0 to 4.6.0 (new option: `allow-cuddle-used-in-block`) 4. Linters bug fixes - `bidichk`: from 0.3.2 to 0.3.3 - `errchkjson`: from 0.4.0 to 0.4.1 - `errname`: from 1.0.0 to 1.1.0 - `funlen`: fix `ignore-comments` option - `gci`: from 0.13.5 to 0.13.6 - `gosmopolitan`: from 1.2.2 to 1.3.0 - `inamedparam`: from 0.1.3 to 0.2.0 - `intrange`: from 0.3.0 to 0.3.1 - `protogetter`: from 0.3.9 to 0.3.12 - `unparam`: from [`8a5130c`](https://github.com/golangci/golangci-lint/commit/8a5130ca722f) to [`0df0534`](https://github.com/golangci/golangci-lint/commit/0df0534333a4) 5. Misc. - ๐Ÿงน Configuration options renaming (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/)) - ๐Ÿงน Remove options (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/)) - ๐Ÿงน Remove flags (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/)) - ๐Ÿงน Remove alternative names (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/#alternative-linter-names)) - ๐Ÿงน Remove or replace deprecated elements (cf. [Migration guide](https://golangci-lint.run/product/migration-guide/)) - Adds an option to display some commands as JSON: - `golangci-lint config path --json` - `golangci-lint help linters --json` - `golangci-lint help formatters --json` - `golangci-lint linters --json` - `golangci-lint formatters --json` - `golangci-lint version --json` 6. Documentation - [Migration guide](https://golangci-lint.run/product/migration-guide/)
--- ### Configuration ๐Ÿ“… **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC). ๐Ÿšฆ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. โ™ป **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. ๐Ÿ”• **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Co-authored-by: Earl Warren Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/705 Reviewed-by: earl-warren Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- .golangci.yml | 309 ++++++++++++++++++++++++++------------------------ Makefile | 2 +- 2 files changed, 159 insertions(+), 152 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 14a41aa4..72e7a7c2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,158 +1,165 @@ +version: "2" linters: + default: none enable: - - gosimple - - typecheck - - govet - - errcheck - - staticcheck - - unused - - dupl - #- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time. - - gofmt - - misspell - - gocritic - bidichk - - ineffassign - - revive - - gofumpt - depguard + - dupl + - errcheck + - gocritic + - govet + - ineffassign + - misspell - nakedret - - unconvert - - wastedassign - nolintlint - - stylecheck - enable-all: false - disable-all: true - fast: false - -run: - timeout: 10m - -linters-settings: - stylecheck: - checks: ["all", "-ST1005", "-ST1003"] - nakedret: - max-func-lines: 0 - gocritic: - disabled-checks: - - ifElseChain - - singleCaseSwitch # Every time this occurred in the code, there was no other way. - revive: - ignore-generated-header: false - severity: warning - confidence: 0.8 - errorCode: 1 - warningCode: 1 + - revive + - staticcheck + - unconvert + - unused + - wastedassign + settings: + depguard: + rules: + main: + deny: + - pkg: io/ioutil + desc: use os or io instead + gocritic: + disabled-checks: + - ifElseChain + - singleCaseSwitch + nakedret: + max-func-lines: 0 + revive: + confidence: 0.8 + severity: warning + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: exported + - name: if-return + - name: increment-decrement + - name: var-naming + - name: var-declaration + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: duplicated-imports + - name: modifies-value-receiver + staticcheck: + checks: + - all + - -ST1003 + - -ST1005 + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling rules: - - name: blank-imports - - name: context-as-argument - - name: context-keys-type - - name: dot-imports - - name: error-return - - name: error-strings - - name: error-naming - - name: exported - - name: if-return - - name: increment-decrement - - name: var-naming - - name: var-declaration - - name: package-comments - - name: range - - name: receiver-naming - - name: time-naming - - name: unexported-return - - name: indent-error-flow - - name: errorf - - name: duplicated-imports - - name: modifies-value-receiver - gofumpt: - extra-rules: true - depguard: - rules: - main: - deny: - - pkg: io/ioutil - desc: use os or io instead - -issues: - exclude-rules: - # Exclude some linters from running on tests files. - - path: _test\.go - linters: - - gocyclo - - errcheck - - dupl - - gosec - - unparam - - staticcheck - - path: models/migrations/v - linters: - - gocyclo - - errcheck - - dupl - - gosec - - linters: - - dupl - text: "webhook" - - linters: - - gocritic - text: "`ID' should not be capitalized" - - path: modules/templates/helper.go - linters: - - gocritic - - linters: - - unused - text: "swagger" - - path: contrib/pr/checkout.go - linters: - - errcheck - - path: models/issue.go - linters: - - errcheck - - path: models/migrations/ - linters: - - errcheck - - path: modules/log/ - linters: - - errcheck - - path: routers/api/v1/repo/issue_subscription.go - linters: - - dupl - - path: routers/repo/view.go - linters: - - dupl - - path: models/migrations/ - linters: - - unused - - linters: - - staticcheck - text: "argument x is overwritten before first use" - - path: modules/httplib/httplib.go - linters: - - staticcheck - # Enabling this would require refactoring the methods and how they are called. - - path: models/issue_comment_list.go - linters: - - dupl - - linters: - - misspell - text: '`Unknwon` is a misspelling of `Unknown`' - - path: models/update.go - linters: - - unused - - path: cmd/dump.go - linters: - - dupl - - text: "commentFormatting: put a space between `//` and comment text" - linters: - - gocritic - - text: "exitAfterDefer:" - linters: - - gocritic - - path: modules/graceful/manager_windows.go - linters: - - staticcheck - text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead." - - path: models/user/openid.go - linters: - - golint + - linters: + - dupl + - errcheck + - gocyclo + - gosec + - staticcheck + - unparam + path: _test\.go + - linters: + - dupl + - errcheck + - gocyclo + - gosec + path: models/migrations/v + - linters: + - dupl + text: webhook + - linters: + - gocritic + text: '`ID'' should not be capitalized' + - linters: + - gocritic + path: modules/templates/helper.go + - linters: + - unused + text: swagger + - linters: + - errcheck + path: contrib/pr/checkout.go + - linters: + - errcheck + path: models/issue.go + - linters: + - errcheck + path: models/migrations/ + - linters: + - errcheck + path: modules/log/ + - linters: + - dupl + path: routers/api/v1/repo/issue_subscription.go + - linters: + - dupl + path: routers/repo/view.go + - linters: + - unused + path: models/migrations/ + - linters: + - staticcheck + text: argument x is overwritten before first use + - linters: + - staticcheck + path: modules/httplib/httplib.go + - linters: + - dupl + path: models/issue_comment_list.go + - linters: + - misspell + text: '`Unknwon` is a misspelling of `Unknown`' + - linters: + - unused + path: models/update.go + - linters: + - dupl + path: cmd/dump.go + - linters: + - gocritic + text: 'commentFormatting: put a space between `//` and comment text' + - linters: + - gocritic + text: 'exitAfterDefer:' + - linters: + - staticcheck + path: modules/graceful/manager_windows.go + text: 'svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead.' + - linters: + - golint + path: models/user/openid.go + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - gofumpt + settings: + gofumpt: + extra-rules: true + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index 82df4a96..619f0cd5 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ GO_FMT_FILES := $(shell find . -type f -name "*.go" ! -name "generated.*") GOFILES := $(shell find . -type f -name "*.go" -o -name "go.mod" ! -name "generated.*") MOCKERY_PACKAGE ?= github.com/vektra/mockery/v2@v2.53.4 # renovate: datasource=go -GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8 # renovate: datasource=go +GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.2 # renovate: datasource=go DOCKER_IMAGE ?= gitea/act_runner DOCKER_TAG ?= nightly