From f0888c35adefc21ed2b95019793075ed55e3d9b4 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Tue, 18 Feb 2025 19:26:08 +0200 Subject: [PATCH 01/15] docs: add migration guide --- docs/src/config/sidebar.yml | 3 +- docs/src/docs/product/migration-guide.mdx | 368 ++++++++++++++++++++++ 2 files changed, 370 insertions(+), 1 deletion(-) create mode 100644 docs/src/docs/product/migration-guide.mdx diff --git a/docs/src/config/sidebar.yml b/docs/src/config/sidebar.yml index af27e37d9bd5..5be19845c318 100644 --- a/docs/src/config/sidebar.yml +++ b/docs/src/config/sidebar.yml @@ -26,6 +26,8 @@ link: "/product/thanks/" - label: "Changelog" link: "/product/changelog/" + - label: "Migration Guide" + link: "/product/migration-guide/" - label: "Roadmap" link: "/product/roadmap/" - label: "Performance" @@ -54,4 +56,3 @@ link: /plugins/module-plugins/ - label: Go Plugin System link: /plugins/go-plugins/ - diff --git a/docs/src/docs/product/migration-guide.mdx b/docs/src/docs/product/migration-guide.mdx new file mode 100644 index 000000000000..86820e5272c8 --- /dev/null +++ b/docs/src/docs/product/migration-guide.mdx @@ -0,0 +1,368 @@ +--- +title: Migration guide +--- + +## Migrating configuration from v1 to v2 + +Golangci-lint v2 has slightly different configuration options than v1. +Some options were renamed, some were moved, some were split, and some were removed. +Here is a guide how to migrate your v1 configuration. + +You can use `golangci-lint` itself to migrate your configuration automatically through the `migrate` command: + +```sh +golangci-lint migrate +``` + +In case you want to do it manually, here is a list of changes. + +--- + +### `linters` configuration + +#### Replaced + +1. `linters.disable-all` replaced with `linters.default: none`. + +
+v1 + +```yaml +linters: + disable-all: true +``` + +
+ +
+v2 + +```yaml +linters: + default: none +``` + +
+ +See [golangci-lint#5474](https://github.com/golangci/golangci-lint/pull/5475) for more details. + +2. `linters.enable-all` replaced with `linters.default: all`. + +
+v1 + +```yaml +linters: + enable-all: true +``` + +
+ +
+v2 + +```yaml +linters: + default: all +``` + +
+ +See [golangci-lint#5474](https://github.com/golangci/golangci-lint/pull/5475) for more details. + +--- + +### `linters-settings` configuration + +#### Split + +1. `linters-settings` section split to `linters.settings` and `formatters.settings`. + +Most linters settings are now in the `linters.settings` section. +Settings for `gci`, `gofmt`, `gofumpt`, `goimports` are moved to the `formatters.settings` section. + +
+v1 + +```yaml +linters-settings: + gofmt: + simplify: true + govet: + disable-all: true +``` + +
+ +
+v2 + +```yaml +linters: + settings: + govet: + disable-all: true + +formatters: + settings: + gofmt: + simplify: true +``` + +
+ +See [golangci-lint#5474](https://github.com/golangci/golangci-lint/pull/5475) for more details. + +--- + +### `issues` configuration + +#### Removed + +1. `issues.exclude-case-sensitive` option. + +`issues.exclude` and `issues.exclude-rules` are case sensitive by default. +To ignore case, use `(?i)` at the beginning of a regex syntax. + +
+v1 + +```yaml +issues: + exclude-case-sensitive: false + exclude: + - 'abcdef' +``` + +
+ +
+v2 + +```yaml +issues: + exclude: + - '(?i)abcdef' +``` + +
+ +See [golangci-lint#5451](https://github.com/golangci/golangci-lint/pull/5451) for more details. + +2. `issues.exclude-dirs-use-default` option. + +
+v1 + +```yaml +issues: + exclude-dirs-use-default: false +``` + +
+ +
+v2 + +TODO + +
+ + +See [golangci-lint#5451](https://github.com/golangci/golangci-lint/pull/5451) for more details. + +#### Replaced + +1. `exclude-dirs` and `exclude-files` replaced with `exclusions.paths`. + +
+v1 + +```yaml +issues: + exclude-dirs: + - src/external_libs + - autogenerated_by_my_lib + + exclude-files: + - ".*\\.my\\.go$" + - lib/bad.go +``` + +
+ +
+v2 + +```yaml +issues: + exclusions: + paths: + - src/external_libs + - autogenerated_by_my_lib + - ".*\\.my\\.go$" + - lib/bad.go +``` + +
+ +2. `issues.exclude-generated-strict` and `issues.exclude-generated` replaced with `linters.exclusions.generated`. + +
+v1 + +```yaml +issues: + exclude-generated-strict: true + exclude-generated: strict +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + generated: strict +``` + +
+ +--- + +### `output` configuration + +#### Replaced + +1. `output.format` replaced with `output.formats`. + +Deprecated since [v1.57.0](https://golangci-lint.run/product/changelog/#v1570). + +
+v1 + +```yaml +output: + format: "checkstyle:report.xml,json:stdout,colored-line-number" +``` + +
+ +
+v2 + +```yaml +output: + formats: + - format: checkstyle + path: report.xml + - format: json + path: stdout + - format: colored-line-number +``` + +
+ +See [golangci-lint#4521](https://github.com/golangci/golangci-lint/pull/4521) for more details. + +#### Changed + +1. `output.show-stats` is `true` by default. + +
+v1 + +```yaml +output: + # show-stats is not present +``` + +
+ +
+v2 + +```yaml +output: + show-stats: true +``` + +
+ +See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details. + +--- + +### `run` configuration + +#### Changed + +1. `run.go` fallback to `1.23`. + +In v1, `run.go` fallback to `1.17`. + +See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details. + +2. `run.timeout` is `0` (disabled) by default. + +In v1, `run.timeout` was `1m` by default. + +
+v1 + +```yaml +run: + # timeout is not present +``` + +
+ +
+v2 + +```yaml +run: + timeout: 1m +``` + +
+ +See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details. + +3. `run.concurrency` set to match Linux container CPU quota by default. + +In v1, `run.concurrency` was set to the number of logical CPUs in the machine. + +See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details. + +--- + +### `severity` configuration + +#### Renamed + +1. `severity.default-severity` renamed to `severity.default`. + +
+v1 + +```yaml +severity: + default-severity: error +``` + +
+ +
+v2 + +```yaml +severity: + default: error +``` + +
+ +See [golangci-lint#5462](https://github.com/golangci/golangci-lint/pull/5462) for more details. From 7c0462b2166ab04b2873fce8d4111949933042db Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Fri, 7 Mar 2025 13:18:30 +0200 Subject: [PATCH 02/15] Add TODO for run.timeout --- docs/src/docs/product/migration-guide.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/src/docs/product/migration-guide.mdx b/docs/src/docs/product/migration-guide.mdx index 86820e5272c8..a0c09c96be69 100644 --- a/docs/src/docs/product/migration-guide.mdx +++ b/docs/src/docs/product/migration-guide.mdx @@ -307,6 +307,8 @@ See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) fo 2. `run.timeout` is `0` (disabled) by default. +TODO: see https://github.com/golangci/golangci-lint/pull/5506#discussion_r1984001235 + In v1, `run.timeout` was `1m` by default.
From 4c5d36628bcee8c0d0fa93d1717065d15f8c92c3 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 8 Mar 2025 22:49:03 +0100 Subject: [PATCH 03/15] chore: add all migration options --- .../src/docs/product/migration-guide-base.mdx | 1662 +++++++++++++++++ 1 file changed, 1662 insertions(+) create mode 100644 docs/src/docs/product/migration-guide-base.mdx diff --git a/docs/src/docs/product/migration-guide-base.mdx b/docs/src/docs/product/migration-guide-base.mdx new file mode 100644 index 000000000000..908d3b53c8b8 --- /dev/null +++ b/docs/src/docs/product/migration-guide-base.mdx @@ -0,0 +1,1662 @@ +--- +title: Migration guide +--- + +## Command `migrate` + +You can use `golangci-lint` to migrate your configuration through the `migrate` command: + +```sh +golangci-lint migrate +``` + +**Configuration comments are not migrated.** + +**Deprecated options from the v1 or unknown fields are not migrated.** + +The migration file format is based on the extension of the configuration file. +The format can be overridden by using `--format` flag. (ex: `golangci-lint migrate --format yml`) + +Before the migration, the previous configuration file is copied and saved to a file named `.bck.`. + +By default, before the migration process, the configuration file is validated against the JSON Schema of the configuration v1. +If you want to skip this validation, you can use `--skip-validation`. (ex: `golangci-lint migrate --skip-validation`) + +The `migrate` command also enforced some new default values: +- `run.timeout`: the existing value is ignored, because, in v2, by default, there is no timeout. +- `issues.show-stats`: the existing value is ignored, in v2, by default, the stats are enabled. +- `run.concurrency`: if the existing value was `0`, as it's the new default, the key is removed. +- `run.relative-path-mode`: if the existing value was `cfg`, as it's the new default, the key is removed. + +`issues.exclude-generated` has a new default value (v1 `lax`, v2 `strict`), then this field will be added during the migration to keep the previous behavior. + +`issues.exclude-dirs-use-default` has been removed, so this is converted to `linters.exclusions.paths` and, if needed, `formatters.exclusions.paths`. + +Other fields, which are explicitly defined in the configuration file, are migrated even if the value is the same as the default value. + +``` +Migrate configuration file from v1 to v2 + +Usage: + golangci-lint migrate [flags] + +Flags: + -c, --config PATH Read config from file path PATH + --no-config Don't read config file + --format string Output file format. + By default, the format of the input configuration file is used. + It can be 'yml', 'yaml', 'toml', or 'json'. + --skip-validation Skip validation of the configuration file against the JSON Schema for v1. + +Global Flags: + -h, --help Help for a command + +``` + +## Changes + +### `issues` + +#### `issues.exclude-case-sensitive` + +`issues.exclude`, `issues.exclude-rules.text`, and `issues.exclude-rules.source` are case-sensitive by default. + +To ignore case, use `(?i)` at the beginning of a regex syntax. + +
+ v1 + + ```yaml + issues: + exclude-case-sensitive: false + exclude: + - 'abcdef' + ``` + +
+ +
+ v2 + + ```yaml + + linters: + exclusions: + rules: + - path: (.+)\.go$ + text: (?i)abcdef + ``` + +
+ +#### `issues.exclude-dirs-use-default` + +
v1 + + ```yml + issues: + exclude-dirs-use-default: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + paths: + - third_party$ + - builtin$ + - examples$ + ``` + +
+ + +#### `issues.exclude-dirs` + +
v1 + + ```yml + issues: + exclude-dirs: + - src/external_libs + - autogenerated_by_my_lib + ``` + +
+ +
v2 + + ```yml + version: "2" + linters: + exclusions: + paths: + - src/external_libs + - autogenerated_by_my_lib + ``` + +
+ +#### `issues.exclude-files` + +
v1 + + ```yml + issues: + exclude-files: + - ".*\\.my\\.go$" + - lib/bad.go + + ``` + +
+ +
v2 + + ```yml + version: "2" + linters: + exclusions: + paths: + - .*\.my\.go$ + - lib/bad.go + ``` + +
+ +#### `issues.exclude-generated-strict` + +Deprecated since v1.59.0. + +
v1 + + ```yml + linters: + exclude-generated-strict: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + generated: strict + ``` + +
+ +#### `issues.exclude-generated` + +
v1 + + ```yml + linters: + exclude-generated: strict + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + generated: strict + ``` + +
+ +#### `issues.exclude-rules` + +
v1 + + ```yml + issues: + exclude-rules: + - path: _test\.go + linters: + - gocyclo + - errcheck + - dupl + - gosec + - path-except: _test\.go + linters: + - staticcheck + - path: internal/hmac/ + text: "weak cryptographic primitive" + linters: + - gosec + - linters: + - staticcheck + text: "SA9003:" + - linters: + - err113 + source: "foo" + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + rules: + - path: _test\.go + linters: + - dupl + - errcheck + - gocyclo + - gosec + - path-except: _test\.go + linters: + - staticcheck + + - path: internal/hmac/ + text: weak cryptographic primitive + linters: + - gosec + - text: 'SA9003:' + linters: + - staticcheck + - source: foo + linters: + - err113 + ``` + +
+ +#### `issues.exclude-use-default` + +
v1 + + ```yml + issues: + exclude-use-default: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + ``` + +
+ +#### `issues.exclude` + +
v1 + + ```yml + issues: + exclude: + - abcdef + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + rules: + - path: (.+)\.go$ + text: abcdef + ``` + +
+ +#### `issues.include` + +
v1 + + ```yml + issues: + include: + - EXC0014 + - EXC0015 + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + presets: + - common-false-positives + - legacy + - std-error-handling + ``` + +
+ +### `linters-settings` + +`linters-settings` section split to `linters.settings` and `formatters.settings`. + +Settings for `gci`, `gofmt`, `gofumpt`, `goimports` are moved to the `formatters.settings` section. + +
v1 + + ```yml + + linters-settings: + lintera: + opt1: foo + # ... + formattera: + opt1: foo + # ... + ``` + +
+ +
v2 + + ```yml + linters: + # ... + settings: + lintera: + opt1: foo + # ... + + formatters: + # ... + settings: + formattera: + opt1: foo + # ... + ``` + +
+ +#### `linters-settings.asasalint.ignore-test` + +
v1 + + ```yml + linters-settings: + asasalint: + ignore-test: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + rules: + - path: (.+)_test\.go + linters: + - asasalint + ``` + +
+ +#### `linters-settings.copyloopvar.ignore-alias` + +Deprecated since v1.58.0. + +
v1 + + ```yml + linters-settings: + copyloopvar: + ignore-alias: false + ``` + +
+ +
v2 + + ```yml + linters: + settings: + copyloopvar: + check-alias: true + ``` + +
+ +#### `linters-settings.cyclop.skip-tests` + +
v1 + + ```yml + linters-settings: + cyclop: + skip-test: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + rules: + - path: (.+)_test\.go + linters: + - cyclop + ``` + +
+ +#### `linters-settings.errcheck.exclude` + +Deprecated since v1.42.0. + +
v1 + + ```yml + linters-settings: + errcheck: + exclude: /foobar.txt + + ``` + +
+ +
v2 + + ```yml + linters: + settings: + errcheck: + exclude-functions: + - example.ReadFile + - example.Copy(*bytes.Buffer) + - example.Copy(os.Stdout) + ``` + +
+ +#### `linters-settings.errcheck.ignore` + +Deprecated since v1.13.0. + +
v1 + + ```yml + linters-settings: + errcheck: + ignore: 'example:.*' + + ``` + +
+ +
v2 + + ```yml + linters: + settings: + errcheck: + exclude-functions: + - example.ReadFile + - example.Copy(*bytes.Buffer) + - example.Copy(os.Stdout) + ``` + +
+ +#### `linters-settings.exhaustive.check-generated` + +
v1 + + ```yml + linters-settings: + exhaustive: + check-generated: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + generated: strict + ``` + +
+ +#### `linters-settings.forbidigo.forbid[].p` + +
v1 + + ```yml + linters-settings: + forbidigo: + forbid: + - p: ^fmt\.Print.*$ + msg: Do not commit print statements. + ``` + +
+ +
v2 + + ```yml + version: "2" + linters: + settings: + forbidigo: + forbid: + - pattern: ^fmt\.Print.*$ + msg: Do not commit print statements. + ``` + +
+ +#### `linters-settings.forbidigo.forbid[].xxx` + +
v1 + + ```yml + linters-settings: + forbidigo: + forbid: + - ^print(ln)?$ + - ^spew\.(ConfigState\.)?Dump$ + ``` + +
+ +
v2 + + ```yml + version: "2" + linters: + settings: + forbidigo: + forbid: + - pattern: ^print(ln)?$ + - pattern: ^spew\.(ConfigState\.)?Dump$ + ``` + +
+ + +#### `linters-settings.gci.local-prefixes` + +Deprecated since v1.44.0. + +
v1 + + ```yml + linters-settings: + gci: + local-prefixes: 'github.com/example/foo' + ``` + +
+ +
v2 + + ```yml + linters: + settings: + gci: + sections: + - standard + - default + - prefix(github.com/example/foo) + ``` + +
+ +#### `linters-settings.gci.skip-generated` + +
v1 + + ```yml + + linters: + settings: + gci: + skip-generated: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + generated: strict + ``` + +
+ +#### `linters-settings.goconst.ignore-tests` + +
v1 + + ```yml + linters-settings: + goconst: + ignore-tests: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + rules: + - path: (.+)_test\.go + linters: + - goconst + ``` + +
+ +#### `linters-settings.godot.check-all` + +Deprecated since v1.33.0. + +
v1 + + ```yml + linters-settings: + godot: + check-all: true + ``` + +
+ +
v2 + + ```yml + linters: + settings: + godot: + scope: all + ``` + +
+ +#### `linters-settings.gofumpt.lang-version` + +Deprecated since v1.v1.0. + +
v1 + + ```yml + linters-settings: + gofumpt: + lang-version: '1.22' + ``` + +
+ +
v2 + + ```yml + run: + go: '1.22' + ``` + +
+ +#### `linters-settings.goimports.local-prefixes` + +
v1 + + ```yml + linters-settings: + goimports: + local-prefixes: 'github.com/example/foo,github.com/example/bar' + ``` + +
+ +
v2 + + ```yml + linters: + settings: + goimports: + local-prefixes: + - github.com/example/foo + - github.com/example/bar + ``` + +
+ +#### `linters-settings.gomodguard.local_replace_directives` + +
v1 + + ```yml + linters-settings: + gomodguard: + local_replace_directives: true + ``` + +
+ +
v2 + + ```yml + linters: + settings: + gomodguard: + local-replace-directives: true + ``` + +
+ +#### `linters-settings.gosec.exclude-generated` + +
v1 + + ```yml + linters-settings: + gosec: + exclude-generated: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + generated: strict + ``` + +
+ +#### `linters-settings.gosimple.go` + +Deprecated since v1.47.0. + +
v1 + + ```yml + linters-settings: + gosimple: + go: '1.22' + ``` + +
+ +
v2 + + ```yml + run: + go: '1.22' + ``` + +
+ +#### `linters-settings.gosmopolitan.ignore-tests` + +
v1 + + ```yml + linters-settings: + gosmopolitan: + ignore-tests: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + rules: + - path: (.+)_test\.go + linters: + - gosmopolitan + ``` + +
+ +#### `linters-settings.govet.check-shadowing` + +Deprecated since v1.57.0. + +
v1 + + ```yml + linters-settings: + govet: + check-shadowing: true + ``` + +
+ +
v2 + + ```yml + linters: + settings: + govet: + enable: shadow + ``` + +
+ +#### `linters-settings.misspell.ignore-words` + +
v1 + + ```yml + linters-settings: + misspell: + ignore-words: + - foo + ``` + +
+ +
v2 + + ```yml + linters: + settings: + misspell: + ignore-rules: + - foo + ``` + +
+ +#### `linters-settings.predeclared.ignore` + +
v1 + + ```yml + linters-settings: + predeclared: + ignore: "new,int" + ``` + +
+ +
v2 + + ```yml + linters: + settings: + predeclared: + ignore: + - new + - int + ``` + +
+ +#### `linters-settings.predeclared.q` + +
v1 + + ```yml + linters-settings: + predeclared: + q: true + ``` + +
+ +
v2 + + ```yml + linters: + settings: + predeclared: + qualified-name: true + ``` + +
+ +#### `linters-settings.revive.ignore-generated-header` + +
v1 + + ```yml + linters-settings: + revive: + ignore-generated-header: true + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + generated: strict + ``` + +
+ +#### `linters-settings.sloglint.context-only` + +Deprecated since v1.58.0. + +
v1 + + ```yml + linters-settings: + sloglint: + context-only: true + ``` + +
+ +
v2 + + ```yml + linters: + settings: + sloglint: + context: all + ``` + +
+ +#### `linters-settings.staticcheck.go` + +Deprecated since v1.47.0. + +
v1 + + ```yml + linters-settings: + staticcheck: + go: '1.22' + ``` + +
+ +
v2 + + ```yml + run: + go: '1.22' + ``` + +
+ +#### `linters-settings.stylecheck.go` + + +
v1 + + ```yml + linters-settings: + stylecheck: + go: '1.22' + ``` + +
+ +
v2 + + ```yml + run: + go: '1.22' + ``` + +
+ + +#### `linters-settings.unused.exported-is-used` + +Deprecated since v1.60.0. + +
v1 + + ```yml + linters-settings: + unused: + exported-is-used: true + ``` + +
+ +
v2 + + Removed. + +
+ +#### `linters-settings.usestdlibvars.os-dev-null` + +Deprecated since v1.51.0. + +
v1 + + ```yml + linters-settings: + usestdlibvars: + os-dev-null: true + ``` + +
+ +
v2 + + Removed. + +
+ +#### `linters-settings.usestdlibvars.syslog-priority` + +Deprecated since v1.51.0. + +
v1 + + ```yml + linters-settings: + usestdlibvars: + syslog-priority: true + ``` + +
+ +
v2 + + Removed. + +
+ +#### `linters-settings.wrapcheck.ignoreInterfaceRegexps` + +
v1 + + ```yml + linters-settings: + wrapcheck: + ignoreInterfaceRegexps: + - ^(?i)c(?-i)ach(ing|e) + ``` + +
+ +
v2 + + ```yml + linters: + settings: + wrapcheck: + ignore-interface-regexps: + - ^(?i)c(?-i)ach(ing|e) + ``` + +
+ +#### `linters-settings.wrapcheck.ignorePackageGlobs` + +
v1 + + ```yml + linters-settings: + wrapcheck: + ignorePackageGlobs: + - encoding/* + ``` + +
+ +
v2 + + ```yml + linters: + settings: + wrapcheck: + ignore-package-globs: + - encoding/* + ``` + +
+ +#### `linters-settings.wrapcheck.ignoreSigRegexps` + +
v1 + + ```yml + linters-settings: + wrapcheck: + ignoreSigRegexps: + - \.New.*Error\( + ``` + +
+ +
v2 + + ```yml + linters: + settings: + wrapcheck: + ignore-sig-regexps: + - \.New.*Error\( + ``` + +
+ +#### `linters-settings.wrapcheck.ignoreSigs` + +
v1 + + ```yml + linters-settings: + wrapcheck: + ignoreSigs: + - .Errorf( + ``` + +
+ +
v2 + + ```yml + linters: + settings: + wrapcheck: + ignore-sigs: + - .Errorf( + ``` + +
+ +### `output` + +#### `output.format` + +
v1 + + ```yml + output: + format: 'checkstyle:report.xml,json:stdout,colored-line-number' + ``` + +
+ +
v2 + + ```yml + output: + formats: + text: + path: stdout + color: true + json: + path: stdout + checkstyle: + path: report.xml + ``` + +
+ +#### `output.formats[].format: xxx` + +
v1 + + ```yml + output: + formats: + - format: json + path: stderr + - format: checkstyle + path: report.xml + - format: colored-line-number + ``` + +
+ +
v2 + + ```yml + output: + formats: + text: + path: stdout + color: true + json: + path: stdout + checkstyle: + path: report.xml + ``` + +
+ +#### `output.show-stats` + +`output.show-stats` is `true` by default. + +#### `output.sort-order` + +`output.sort-order` has new default: `linter`, `file` instead of `file`. + +#### `output.sort-results` + +`output.sort-results` has been removed: the results are always sorted. + +#### `output.uniq-by-line` + +Deprecated since v1.63.0. + +
v1 + + ```yml + output: + uniq-by-line: true + ``` + +
+ +
v2 + + ```yml + issues: + uniq-by-line: true + ``` + +
+ +### `run` + +#### `run.concurrency` + +`run.concurrency` set to match Linux container CPU quota by default and fallback on the number of logical CPUs in the machine. + +#### `run.show-stats` + +Deprecated since v1.57.0. + +
v1 + + ```yml + run: + show-stats: true + ``` + +
+ +
v2 + + ```yml + output: + show-stats: true + ``` + +
+ +#### `run.skip-dirs-use-default` + +Deprecated since v1.57.0. + +
v1 + + ```yml + run: + skip-dirs-use-default: false + ``` + +
+ +
v2 + + ```yml + issues: + exclude-dirs-use-default: false + ``` + +
+ +#### `run.skip-dirs` + +Deprecated since v1.57.0. + +
v1 + + ```yml + run: + skip-dirs: + - src/external_libs + - autogenerated_by_my_lib + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + paths: + - src/external_libs + - autogenerated_by_my_lib + ``` + +
+ +#### `run.skip-files` + +Deprecated since v1.57.0. + +
v1 + + ```yml + run: + skip-files: + - ".*\\.my\\.go$" + - lib/bad.go + ``` + +
+ +
v2 + + ```yml + linters: + exclusions: + paths: + - ".*\\.my\\.go$" + - lib/bad.go + ``` + +
+ +#### `run.timeout` + +`run.timeout` is disabled (`0`) by default. + +### `severity` + +#### `severity.default-severity` + +
v1 + + ```yml + severity: + default-severity: error + ``` + +
+ +
v2 + + ```yml + severity: + default: error + ``` + +
+ +#### `severity.rules.case-sensitive` + +`severity.rules.text`, and `severity.rules.source` are case-sensitive by default. + +To ignore case, use `(?i)` at the beginning of a regex syntax. + +
v1 + + ```yml + + severity: + case-sensitive: true + rules: + - severity: info + linters: + - foo + text: 'Example.*' + ``` + +
+ +
v2 + + ```yml + severity: + rules: + - severity: info + linters: + - foo + text: '(?i)Example.*' + ``` + +
+ +### `linters` + +#### `linters.disable-all` + +
v1 + + ```yml + linters: + disable-all: true + ``` + +
+ +
v2 + + ```yml + linters: + default: none + ``` + +
+ +#### `linters.enable-all` + +
v1 + + ```yml + linters: + enable-all: true + ``` + +
+ +
v2 + + ```yml + linters: + default: all + ``` + +
+ +#### `linters.fast` + +There is no strictly equivalent option in v2 but 2 new options: + + +To set all "fast" linters as default linters: + +```yml +linters: + default: fast +``` + +The new flag option `--fast-only` filters enabled linters to keep only "fast" linters. + +#### `linters.presets` + +The presets have been removed. + +
v1 Presets + + - ๐Ÿ›: bugs + - ๐Ÿ’ฌ: comment + - ๐Ÿงฎ: complexity + - ๐Ÿ’ข: error + - ๐Ÿ’พ: format + - ๐Ÿ”: import + - ๐ŸŽ›๏ธ: metalinter + - ๐Ÿ“ฆ: module + - ๐Ÿ“Š: performance + - ๐Ÿ—‚๏ธ: sql + - ๐ŸŽฉ: style + - ๐Ÿšฆ: test + - ๐Ÿงน: unused + + | | ๐Ÿ› | ๐Ÿ’ฌ | ๐Ÿงฎ | ๐Ÿ’ข | ๐Ÿ’พ | ๐Ÿ” | ๐ŸŽ›๏ธ๏ธ | ๐Ÿ“ฆ | ๐Ÿ“Š | ๐Ÿ—‚๏ธ๏ธ | ๐ŸŽฉ | ๐Ÿšฆ | ๐Ÿงน | + |-----------------------------|----|----|----|----|----|----|------|----|----|------|----|----|----| + | `asasalint` | ๐Ÿ› | | | | | | | | | | | | | + | `asciicheck` | ๐Ÿ› | | | | | | | | | | ๐ŸŽฉ | | | + | `bidichk` | ๐Ÿ› | | | | | | | | | | | | | + | `bodyclose` | ๐Ÿ› | | | | | | | | ๐Ÿ“Š | | | | | + | `canonicalheader` | | | | | | | | | | | ๐ŸŽฉ | | | + | `containedctx` | | | | | | | | | | | ๐ŸŽฉ | | | + | `contextcheck` | ๐Ÿ› | | | | | | | | | | | | | + | `copyloopvar` | | | | | | | | | | | ๐ŸŽฉ | | | + | `cyclop` | | | ๐Ÿงฎ | | | | | | | | | | | + | `decorder` | | | | | | | | | | | ๐ŸŽฉ | | | + | `depguard` | | | | | | ๐Ÿ” | | ๐Ÿ“ฆ | | | ๐ŸŽฉ | | | + | `dogsled` | | | | | | | | | | | ๐ŸŽฉ | | | + | `dupl` | | | | | | | | | | | ๐ŸŽฉ | | | + | `dupword` | | ๐Ÿ’ฌ | | | | | | | | | | | | + | `durationcheck` | ๐Ÿ› | | | | | | | | | | | | | + | `err113` | | | | ๐Ÿ’ข | | | | | | | ๐ŸŽฉ | | | + | `errcheck` | ๐Ÿ› | | | ๐Ÿ’ข | | | | | | | | | | + | `errchkjson` | ๐Ÿ› | | | | | | | | | | | | | + | `errname` | | | | | | | | | | | ๐ŸŽฉ | | | + | `errorlint` | ๐Ÿ› | | | ๐Ÿ’ข | | | | | | | | | | + | `exhaustive` | ๐Ÿ› | | | | | | | | | | | | | + | `exhaustruct` | | | | | | | | | | | ๐ŸŽฉ | ๐Ÿšฆ | | + | `exptostd` | | | | | | | | | | | ๐ŸŽฉ | | | + | `fatcontext` | | | | | | | | | ๐Ÿ“Š | | | | | + | `forbidigo` | | | | | | | | | | | ๐ŸŽฉ | | | + | `forcetypeassert` | | | | | | | | | | | ๐ŸŽฉ | | | + | `funlen` | | | ๐Ÿงฎ | | | | | | | | | | | + | `gci` | | | | | ๐Ÿ’พ | ๐Ÿ” | | | | | | | | + | `ginkgolinter` | | | | | | | | | | | ๐ŸŽฉ | | | + | `gocheckcompilerdirectives` | ๐Ÿ› | | | | | | | | | | | | | + | `gochecknoglobals` | | | | | | | | | | | ๐ŸŽฉ | | | + | `gochecknoinits` | | | | | | | | | | | ๐ŸŽฉ | | | + | `gochecksumtype` | ๐Ÿ› | | | | | | | | | | | | | + | `gocognit` | | | ๐Ÿงฎ | | | | | | | | | | | + | `goconst` | | | | | | | | | | | ๐ŸŽฉ | | | + | `gocritic` | | | | | | | ๐ŸŽ›๏ธ | | | | ๐ŸŽฉ | | | + | `gocyclo` | | | ๐Ÿงฎ | | | | | | | | | | | + | `godot` | | ๐Ÿ’ฌ | | | | | | | | | ๐ŸŽฉ | | | + | `godox` | | ๐Ÿ’ฌ | | | | | | | | | ๐ŸŽฉ | | | + | `gofmt` | | | | | ๐Ÿ’พ | | | | | | | | | + | `gofumpt` | | | | | ๐Ÿ’พ | | | | | | | | | + | `goheader` | | | | | | | | | | | ๐ŸŽฉ | | | + | `goimports` | | | | | ๐Ÿ’พ | ๐Ÿ” | | | | | | | | + | `gomoddirectives` | | | | | | | | ๐Ÿ“ฆ | | | ๐ŸŽฉ | | | + | `gomodguard` | | | | | | ๐Ÿ” | | ๐Ÿ“ฆ | | | ๐ŸŽฉ | | | + | `goprintffuncname` | | | | | | | | | | | ๐ŸŽฉ | | | + | `gosec` | ๐Ÿ› | | | | | | | | | | | | | + | `gosimple` | | | | | | | | | | | ๐ŸŽฉ | | | + | `gosmopolitan` | ๐Ÿ› | | | | | | | | | | | | | + | `govet` | ๐Ÿ› | | | | | | ๐ŸŽ›๏ธ | | | | | | | + | `grouper` | | | | | | | | | | | ๐ŸŽฉ | | | + | `iface` | | | | | | | | | | | ๐ŸŽฉ | | | + | `importas` | | | | | | | | | | | ๐ŸŽฉ | | | + | `inamedparam` | | | | | | | | | | | ๐ŸŽฉ | | | + | `ineffassign` | | | | | | | | | | | | | ๐Ÿงน | + | `interfacebloat` | | | | | | | | | | | ๐ŸŽฉ | | | + | `intrange` | | | | | | | | | | | ๐ŸŽฉ | | | + | `ireturn` | | | | | | | | | | | ๐ŸŽฉ | | | + | `lll` | | | | | | | | | | | ๐ŸŽฉ | | | + | `loggercheck` | ๐Ÿ› | | | | | | | | | | ๐ŸŽฉ | | | + | `maintidx` | | | ๐Ÿงฎ | | | | | | | | | | | + | `makezero` | ๐Ÿ› | | | | | | | | | | ๐ŸŽฉ | | | + | `mirror` | | | | | | | | | | | ๐ŸŽฉ | | | + | `misspell` | | ๐Ÿ’ฌ | | | | | | | | | ๐ŸŽฉ | | | + | `mnd` | | | | | | | | | | | ๐ŸŽฉ | | | + | `musttag` | ๐Ÿ› | | | | | | | | | | ๐ŸŽฉ | | | + | `nakedret` | | | | | | | | | | | ๐ŸŽฉ | | | + | `nestif` | | | ๐Ÿงฎ | | | | | | | | | | | + | `nilerr` | ๐Ÿ› | | | | | | | | | | | | | + | `nilnesserr` | ๐Ÿ› | | | | | | | | | | | | | + | `nilnil` | | | | | | | | | | | ๐ŸŽฉ | | | + | `nlreturn` | | | | | | | | | | | ๐ŸŽฉ | | | + | `noctx` | ๐Ÿ› | | | | | | | | ๐Ÿ“Š | | | | | + | `nolintlint` | | | | | | | | | | | ๐ŸŽฉ | | | + | `nonamedreturns` | | | | | | | | | | | ๐ŸŽฉ | | | + | `nosprintfhostport` | | | | | | | | | | | ๐ŸŽฉ | | | + | `paralleltest` | | | | | | | | | | | ๐ŸŽฉ | ๐Ÿšฆ | | + | `perfsprint` | | | | | | | | | ๐Ÿ“Š | | | | | + | `prealloc` | | | | | | | | | ๐Ÿ“Š | | | | | + | `predeclared` | | | | | | | | | | | ๐ŸŽฉ | | | + | `promlinter` | | | | | | | | | | | ๐ŸŽฉ | | | + | `protogetter` | ๐Ÿ› | | | | | | | | | | | | | + | `reassign` | ๐Ÿ› | | | | | | | | | | | | | + | `recvcheck` | ๐Ÿ› | | | | | | | | | | | | | + | `revive` | | | | | | | ๐ŸŽ›๏ธ | | | | ๐ŸŽฉ | | | + | `rowserrcheck` | ๐Ÿ› | | | | | | | | | ๐Ÿ—‚๏ธ | | | | + | `sloglint` | | | | | | | | | | | ๐ŸŽฉ | | | + | `spancheck` | ๐Ÿ› | | | | | | | | | | | | | + | `sqlclosecheck` | ๐Ÿ› | | | | | | | | | ๐Ÿ—‚๏ธ | | | | + | `staticcheck` | ๐Ÿ› | | | | | | ๐ŸŽ›๏ธ | | | | | | | + | `stylecheck` | | | | | | | | | | | ๐ŸŽฉ | | | + | `tagalign` | | | | | | | | | | | ๐ŸŽฉ | | | + | `tagliatelle` | | | | | | | | | | | ๐ŸŽฉ | | | + | `tenv` | | | | | | | | | | | | ๐Ÿšฆ | | + | `testableexamples` | | | | | | | | | | | | ๐Ÿšฆ | | + | `testifylint` | ๐Ÿ› | | | | | | | | | | | ๐Ÿšฆ | | + | `testpackage` | | | | | | | | | | | ๐ŸŽฉ | ๐Ÿšฆ | | + | `thelper` | | | | | | | | | | | | ๐Ÿšฆ | | + | `tparallel` | | | | | | | | | | | ๐ŸŽฉ | ๐Ÿšฆ | | + | `unconvert` | | | | | | | | | | | ๐ŸŽฉ | | | + | `unparam` | | | | | | | | | | | | | ๐Ÿงน | + | `unused` | | | | | | | | | | | | | ๐Ÿงน | + | `usestdlibvars` | | | | | | | | | | | ๐ŸŽฉ | | | + | `usetesting` | | | | | | | | | | | | ๐Ÿšฆ | | + | `varnamelen` | | | | | | | | | | | ๐ŸŽฉ | | | + | `wastedassign` | | | | | | | | | | | ๐ŸŽฉ | | | + | `whitespace` | | | | | | | | | | | ๐ŸŽฉ | | | + | `wrapcheck` | | | | ๐Ÿ’ข | | | | | | | ๐ŸŽฉ | | | + | `wsl` | | | | | | | | | | | ๐ŸŽฉ | | | + | `zerologlint` | ๐Ÿ› | | | | | | | | | | | | | + +
+ +### Alternative Linter Names + +The alternative linters has been removed. + +| Alt Name v1 | v2 Name | +|-------------|---------------| +| `gas` | `gosec` | +| `goerr113` | `err113` | +| `gomnd` | `mnd` | +| `logrlint` | `loggercheck` | +| `megacheck` | `staticcheck` | +| `vet` | `govet` | +| `vetshadow` | `govet` | + +### `stylecheck`, `gosimple`, `staticcheck` + +The 3 linters `stylecheck`, `gosimple`, `staticcheck` has been merged inside `staticcheck`. From 53f194b8ae5ee7409855a0cae6b55708fb21ecd5 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 8 Mar 2025 23:20:14 +0100 Subject: [PATCH 04/15] chore: fix snippets indentation --- .../src/docs/product/migration-guide-base.mdx | 1144 ++++++++--------- 1 file changed, 566 insertions(+), 578 deletions(-) diff --git a/docs/src/docs/product/migration-guide-base.mdx b/docs/src/docs/product/migration-guide-base.mdx index 908d3b53c8b8..5ceb2c1de04a 100644 --- a/docs/src/docs/product/migration-guide-base.mdx +++ b/docs/src/docs/product/migration-guide-base.mdx @@ -34,7 +34,7 @@ The `migrate` command also enforced some new default values: Other fields, which are explicitly defined in the configuration file, are migrated even if the value is the same as the default value. -``` +```txt Migrate configuration file from v1 to v2 Usage: @@ -66,26 +66,25 @@ To ignore case, use `(?i)` at the beginning of a regex syntax.
v1 - ```yaml - issues: +```yaml +issues: exclude-case-sensitive: false - exclude: - - 'abcdef' - ``` + exclude: + - 'abcdef' +```
v2 - ```yaml - - linters: +```yaml +linters: exclusions: - rules: - - path: (.+)\.go$ - text: (?i)abcdef - ``` + rules: + - path: (.+)\.go$ + text: (?i)abcdef +```
@@ -93,23 +92,23 @@ To ignore case, use `(?i)` at the beginning of a regex syntax.
v1 - ```yml - issues: +```yaml +issues: exclude-dirs-use-default: true - ``` +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - paths: - - third_party$ - - builtin$ - - examples$ - ``` + paths: + - third_party$ + - builtin$ + - examples$ +```
@@ -118,25 +117,24 @@ To ignore case, use `(?i)` at the beginning of a regex syntax.
v1 - ```yml - issues: +```yaml +issues: exclude-dirs: - - src/external_libs - - autogenerated_by_my_lib - ``` + - src/external_libs + - autogenerated_by_my_lib +```
v2 - ```yml - version: "2" - linters: +```yaml +linters: exclusions: - paths: - - src/external_libs - - autogenerated_by_my_lib - ``` + paths: + - src/external_libs + - autogenerated_by_my_lib +```
@@ -144,26 +142,24 @@ To ignore case, use `(?i)` at the beginning of a regex syntax.
v1 - ```yml - issues: +```yaml +issues: exclude-files: - - ".*\\.my\\.go$" - - lib/bad.go - - ``` + - ".*\\.my\\.go$" + - lib/bad.go +```
v2 - ```yml - version: "2" - linters: +```yaml +linters: exclusions: - paths: - - .*\.my\.go$ - - lib/bad.go - ``` + paths: + - .*\.my\.go$ + - lib/bad.go +```
@@ -173,20 +169,20 @@ Deprecated since v1.59.0.
v1 - ```yml - linters: +```yaml +linters: exclude-generated-strict: true - ``` +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - generated: strict - ``` + generated: strict +```
@@ -194,20 +190,20 @@ Deprecated since v1.59.0.
v1 - ```yml - linters: +```yaml +linters: exclude-generated: strict - ``` +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - generated: strict - ``` + generated: strict +```
@@ -215,58 +211,57 @@ Deprecated since v1.59.0.
v1 - ```yml - issues: +```yaml +issues: exclude-rules: - - path: _test\.go - linters: - - gocyclo - - errcheck - - dupl - - gosec - - path-except: _test\.go - linters: - - staticcheck - - path: internal/hmac/ - text: "weak cryptographic primitive" - linters: - - gosec - - linters: - - staticcheck - text: "SA9003:" - - linters: - - err113 - source: "foo" - ``` + - path: _test\.go + linters: + - gocyclo + - errcheck + - dupl + - gosec + - path-except: _test\.go + linters: + - staticcheck + - path: internal/hmac/ + text: "weak cryptographic primitive" + linters: + - gosec + - linters: + - staticcheck + text: "SA9003:" + - linters: + - err113 + source: "foo" +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - rules: - - path: _test\.go - linters: - - dupl - - errcheck - - gocyclo - - gosec - - path-except: _test\.go - linters: - - staticcheck - - - path: internal/hmac/ - text: weak cryptographic primitive - linters: - - gosec - - text: 'SA9003:' - linters: - - staticcheck - - source: foo - linters: - - err113 + rules: + - path: _test\.go + linters: + - dupl + - errcheck + - gocyclo + - gosec + - path-except: _test\.go + linters: + - staticcheck + - path: internal/hmac/ + text: weak cryptographic primitive + linters: + - gosec + - text: 'SA9003:' + linters: + - staticcheck + - source: foo + linters: + - err113 ```
@@ -275,24 +270,24 @@ Deprecated since v1.59.0.
v1 - ```yml - issues: +```yaml +issues: exclude-use-default: true - ``` +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - presets: - - comments - - common-false-positives - - legacy - - std-error-handling - ``` + presets: + - comments + - common-false-positives + - legacy + - std-error-handling +```
@@ -300,23 +295,23 @@ Deprecated since v1.59.0.
v1 - ```yml - issues: +```yaml +issues: exclude: - - abcdef - ``` + - abcdef +```
v2 - ```yml - linters: +```yaml +linters: exclusions: rules: - - path: (.+)\.go$ - text: abcdef - ``` + - path: (.+)\.go$ + text: abcdef +```
@@ -324,25 +319,25 @@ Deprecated since v1.59.0.
v1 - ```yml - issues: +```yaml +issues: include: - - EXC0014 - - EXC0015 - ``` + - EXC0014 + - EXC0015 +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - presets: - - common-false-positives - - legacy - - std-error-handling - ``` + presets: + - common-false-positives + - legacy + - std-error-handling +```
@@ -354,36 +349,35 @@ Settings for `gci`, `gofmt`, `gofumpt`, `goimports` are moved to the `formatters
v1 - ```yml - - linters-settings: +```yaml +linters-settings: lintera: - opt1: foo - # ... + opt1: foo + # ... formattera: - opt1: foo - # ... - ``` + opt1: foo + # ... +```
v2 - ```yml - linters: +```yaml +linters: # ... settings: - lintera: - opt1: foo - # ... + lintera: + opt1: foo + # ... - formatters: +formatters: # ... settings: - formattera: - opt1: foo - # ... - ``` + formattera: + opt1: foo + # ... +```
@@ -391,24 +385,24 @@ Settings for `gci`, `gofmt`, `gofumpt`, `goimports` are moved to the `formatters
v1 - ```yml - linters-settings: +```yaml +linters-settings: asasalint: - ignore-test: true - ``` + ignore-test: true +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - rules: - - path: (.+)_test\.go - linters: - - asasalint - ``` + rules: + - path: (.+)_test\.go + linters: + - asasalint +```
@@ -418,22 +412,22 @@ Deprecated since v1.58.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: copyloopvar: - ignore-alias: false - ``` + ignore-alias: false +```
v2 - ```yml - linters: +```yaml +linters: settings: - copyloopvar: - check-alias: true - ``` + copyloopvar: + check-alias: true +```
@@ -441,24 +435,24 @@ Deprecated since v1.58.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: cyclop: - skip-test: true - ``` + skip-test: true +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - rules: - - path: (.+)_test\.go - linters: - - cyclop - ``` + rules: + - path: (.+)_test\.go + linters: + - cyclop +```
@@ -468,26 +462,25 @@ Deprecated since v1.42.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: errcheck: - exclude: /foobar.txt - - ``` + exclude: /foobar.txt +```
v2 - ```yml - linters: +```yaml +linters: settings: - errcheck: - exclude-functions: - - example.ReadFile - - example.Copy(*bytes.Buffer) - - example.Copy(os.Stdout) - ``` + errcheck: + exclude-functions: + - example.ReadFile + - example.Copy(*bytes.Buffer) + - example.Copy(os.Stdout) +```
@@ -497,26 +490,26 @@ Deprecated since v1.13.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: errcheck: - ignore: 'example:.*' + ignore: 'example:.*' - ``` +```
v2 - ```yml - linters: +```yaml +linters: settings: - errcheck: - exclude-functions: - - example.ReadFile - - example.Copy(*bytes.Buffer) - - example.Copy(os.Stdout) - ``` + errcheck: + exclude-functions: + - example.ReadFile + - example.Copy(*bytes.Buffer) + - example.Copy(os.Stdout) +```
@@ -524,21 +517,21 @@ Deprecated since v1.13.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: exhaustive: - check-generated: true - ``` + check-generated: true +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - generated: strict - ``` + generated: strict +```
@@ -546,27 +539,26 @@ Deprecated since v1.13.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: forbidigo: - forbid: - - p: ^fmt\.Print.*$ - msg: Do not commit print statements. - ``` + forbid: + - p: ^fmt\.Print.*$ + msg: Do not commit print statements. +```
v2 - ```yml - version: "2" - linters: +```yaml +linters: settings: - forbidigo: - forbid: - - pattern: ^fmt\.Print.*$ - msg: Do not commit print statements. - ``` + forbidigo: + forbid: + - pattern: ^fmt\.Print.*$ + msg: Do not commit print statements. +```
@@ -574,27 +566,26 @@ Deprecated since v1.13.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: forbidigo: - forbid: - - ^print(ln)?$ - - ^spew\.(ConfigState\.)?Dump$ - ``` + forbid: + - ^print(ln)?$ + - ^spew\.(ConfigState\.)?Dump$ +```
v2 - ```yml - version: "2" - linters: +```yaml +linters: settings: - forbidigo: - forbid: - - pattern: ^print(ln)?$ - - pattern: ^spew\.(ConfigState\.)?Dump$ - ``` + forbidigo: + forbid: + - pattern: ^print(ln)?$ + - pattern: ^spew\.(ConfigState\.)?Dump$ +```
@@ -605,25 +596,25 @@ Deprecated since v1.44.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: gci: - local-prefixes: 'github.com/example/foo' - ``` + local-prefixes: 'github.com/example/foo' +```
v2 - ```yml - linters: +```yaml +linters: settings: - gci: - sections: - - standard - - default - - prefix(github.com/example/foo) - ``` + gci: + sections: + - standard + - default + - prefix(github.com/example/foo) +```
@@ -631,23 +622,22 @@ Deprecated since v1.44.0.
v1 - ```yml - - linters: +```yaml +linters: settings: - gci: - skip-generated: true - ``` + gci: + skip-generated: true +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - generated: strict - ``` + generated: strict +```
@@ -655,24 +645,24 @@ Deprecated since v1.44.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: goconst: - ignore-tests: true - ``` + ignore-tests: true +```
v2 - ```yml - linters: +```yaml +linters: exclusions: rules: - - path: (.+)_test\.go - linters: - - goconst - ``` + - path: (.+)_test\.go + linters: + - goconst +```
@@ -682,22 +672,22 @@ Deprecated since v1.33.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: godot: - check-all: true - ``` + check-all: true +```
v2 - ```yml - linters: +```yaml +linters: settings: - godot: - scope: all - ``` + godot: + scope: all +```
@@ -707,20 +697,20 @@ Deprecated since v1.v1.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: gofumpt: - lang-version: '1.22' - ``` + lang-version: '1.22' +```
v2 - ```yml - run: +```yaml +run: go: '1.22' - ``` +```
@@ -728,24 +718,24 @@ Deprecated since v1.v1.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: goimports: - local-prefixes: 'github.com/example/foo,github.com/example/bar' - ``` + local-prefixes: 'github.com/example/foo,github.com/example/bar' +```
v2 - ```yml - linters: +```yaml +linters: settings: - goimports: - local-prefixes: - - github.com/example/foo - - github.com/example/bar - ``` + goimports: + local-prefixes: + - github.com/example/foo + - github.com/example/bar +```
@@ -753,22 +743,22 @@ Deprecated since v1.v1.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: gomodguard: - local_replace_directives: true - ``` + local_replace_directives: true +```
v2 - ```yml - linters: +```yaml +linters: settings: - gomodguard: - local-replace-directives: true - ``` + gomodguard: + local-replace-directives: true +```
@@ -776,21 +766,21 @@ Deprecated since v1.v1.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: gosec: - exclude-generated: true - ``` + exclude-generated: true +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - generated: strict - ``` + generated: strict +```
@@ -800,20 +790,20 @@ Deprecated since v1.47.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: gosimple: - go: '1.22' - ``` + go: '1.22' +```
v2 - ```yml - run: +```yaml +run: go: '1.22' - ``` +```
@@ -821,24 +811,24 @@ Deprecated since v1.47.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: gosmopolitan: - ignore-tests: true - ``` + ignore-tests: true +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - rules: - - path: (.+)_test\.go - linters: - - gosmopolitan - ``` + rules: + - path: (.+)_test\.go + linters: + - gosmopolitan +```
@@ -848,22 +838,22 @@ Deprecated since v1.57.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: govet: - check-shadowing: true - ``` + check-shadowing: true +```
v2 - ```yml - linters: +```yaml +linters: settings: - govet: - enable: shadow - ``` + govet: + enable: shadow +```
@@ -871,24 +861,24 @@ Deprecated since v1.57.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: misspell: - ignore-words: - - foo - ``` + ignore-words: + - foo +```
v2 - ```yml - linters: +```yaml +linters: settings: - misspell: - ignore-rules: - - foo - ``` + misspell: + ignore-rules: + - foo +```
@@ -896,24 +886,24 @@ Deprecated since v1.57.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: predeclared: - ignore: "new,int" - ``` + ignore: "new,int" +```
v2 - ```yml - linters: +```yaml +linters: settings: - predeclared: - ignore: - - new - - int - ``` + predeclared: + ignore: + - new + - int +```
@@ -921,22 +911,22 @@ Deprecated since v1.57.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: predeclared: - q: true - ``` + q: true +```
v2 - ```yml - linters: +```yaml +linters: settings: - predeclared: - qualified-name: true - ``` + predeclared: + qualified-name: true +```
@@ -944,21 +934,21 @@ Deprecated since v1.57.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: revive: - ignore-generated-header: true - ``` + ignore-generated-header: true +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - generated: strict - ``` + generated: strict +```
@@ -968,22 +958,22 @@ Deprecated since v1.58.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: sloglint: - context-only: true - ``` + context-only: true +```
v2 - ```yml - linters: +```yaml +linters: settings: - sloglint: - context: all - ``` + sloglint: + context: all +```
@@ -993,20 +983,20 @@ Deprecated since v1.47.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: staticcheck: - go: '1.22' - ``` + go: '1.22' +```
v2 - ```yml - run: +```yaml +run: go: '1.22' - ``` +```
@@ -1015,20 +1005,20 @@ Deprecated since v1.47.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: stylecheck: - go: '1.22' - ``` + go: '1.22' +```
v2 - ```yml - run: +```yaml +run: go: '1.22' - ``` +```
@@ -1039,17 +1029,17 @@ Deprecated since v1.60.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: unused: - exported-is-used: true - ``` + exported-is-used: true +```
v2 - Removed. +Removed.
@@ -1059,17 +1049,17 @@ Deprecated since v1.51.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: usestdlibvars: - os-dev-null: true - ``` + os-dev-null: true +```
v2 - Removed. +Removed.
@@ -1079,17 +1069,17 @@ Deprecated since v1.51.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: usestdlibvars: - syslog-priority: true - ``` + syslog-priority: true +```
v2 - Removed. +Removed.
@@ -1097,24 +1087,24 @@ Deprecated since v1.51.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: wrapcheck: - ignoreInterfaceRegexps: - - ^(?i)c(?-i)ach(ing|e) - ``` + ignoreInterfaceRegexps: + - ^(?i)c(?-i)ach(ing|e) +```
v2 - ```yml - linters: +```yaml +linters: settings: - wrapcheck: - ignore-interface-regexps: - - ^(?i)c(?-i)ach(ing|e) - ``` + wrapcheck: + ignore-interface-regexps: + - ^(?i)c(?-i)ach(ing|e) +```
@@ -1122,24 +1112,24 @@ Deprecated since v1.51.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: wrapcheck: - ignorePackageGlobs: - - encoding/* - ``` + ignorePackageGlobs: + - encoding/* +```
v2 - ```yml - linters: +```yaml +linters: settings: - wrapcheck: - ignore-package-globs: - - encoding/* - ``` + wrapcheck: + ignore-package-globs: + - encoding/* +```
@@ -1147,24 +1137,24 @@ Deprecated since v1.51.0.
v1 - ```yml +```yaml linters-settings: - wrapcheck: - ignoreSigRegexps: - - \.New.*Error\( - ``` + wrapcheck: + ignoreSigRegexps: + - \.New.*Error\( +```
v2 - ```yml - linters: +```yaml +linters: settings: - wrapcheck: - ignore-sig-regexps: - - \.New.*Error\( - ``` + wrapcheck: + ignore-sig-regexps: + - \.New.*Error\( +```
@@ -1172,24 +1162,24 @@ Deprecated since v1.51.0.
v1 - ```yml - linters-settings: +```yaml +linters-settings: wrapcheck: - ignoreSigs: - - .Errorf( - ``` + ignoreSigs: + - .Errorf( +```
v2 - ```yml - linters: +```yaml +linters: settings: - wrapcheck: - ignore-sigs: - - .Errorf( - ``` + wrapcheck: + ignore-sigs: + - .Errorf( +```
@@ -1199,26 +1189,26 @@ Deprecated since v1.51.0.
v1 - ```yml - output: +```yaml +output: format: 'checkstyle:report.xml,json:stdout,colored-line-number' - ``` +```
v2 - ```yml - output: +```yaml +output: formats: - text: - path: stdout - color: true - json: - path: stdout - checkstyle: - path: report.xml - ``` + text: + path: stdout + color: true + json: + path: stdout + checkstyle: + path: report.xml +```
@@ -1226,31 +1216,31 @@ Deprecated since v1.51.0.
v1 - ```yml - output: +```yaml +output: formats: - - format: json - path: stderr - - format: checkstyle - path: report.xml - - format: colored-line-number - ``` + - format: json + path: stderr + - format: checkstyle + path: report.xml + - format: colored-line-number +```
v2 - ```yml - output: +```yaml +output: formats: - text: - path: stdout - color: true - json: - path: stdout - checkstyle: - path: report.xml - ``` + text: + path: stdout + color: true + json: + path: stdout + checkstyle: + path: report.xml +```
@@ -1272,19 +1262,19 @@ Deprecated since v1.63.0.
v1 - ```yml - output: +```yaml +output: uniq-by-line: true - ``` +```
v2 - ```yml - issues: +```yaml +issues: uniq-by-line: true - ``` +```
@@ -1300,19 +1290,19 @@ Deprecated since v1.57.0.
v1 - ```yml - run: +```yaml +run: show-stats: true - ``` +```
v2 - ```yml - output: +```yaml +output: show-stats: true - ``` +```
@@ -1322,19 +1312,19 @@ Deprecated since v1.57.0.
v1 - ```yml - run: +```yaml +run: skip-dirs-use-default: false - ``` +```
v2 - ```yml - issues: +```yaml +issues: exclude-dirs-use-default: false - ``` +```
@@ -1344,24 +1334,24 @@ Deprecated since v1.57.0.
v1 - ```yml - run: +```yaml +run: skip-dirs: - - src/external_libs - - autogenerated_by_my_lib - ``` + - src/external_libs + - autogenerated_by_my_lib +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - paths: - - src/external_libs - - autogenerated_by_my_lib - ``` + paths: + - src/external_libs + - autogenerated_by_my_lib +```
@@ -1371,24 +1361,24 @@ Deprecated since v1.57.0.
v1 - ```yml - run: +```yaml +run: skip-files: - - ".*\\.my\\.go$" - - lib/bad.go - ``` + - ".*\\.my\\.go$" + - lib/bad.go +```
v2 - ```yml - linters: +```yaml +linters: exclusions: - paths: - - ".*\\.my\\.go$" - - lib/bad.go - ``` + paths: + - ".*\\.my\\.go$" + - lib/bad.go +```
@@ -1402,19 +1392,19 @@ Deprecated since v1.57.0.
v1 - ```yml - severity: +```yaml +severity: default-severity: error - ``` +```
v2 - ```yml - severity: +```yaml +severity: default: error - ``` +```
@@ -1426,29 +1416,28 @@ To ignore case, use `(?i)` at the beginning of a regex syntax.
v1 - ```yml - - severity: +```yaml +severity: case-sensitive: true rules: - - severity: info - linters: - - foo - text: 'Example.*' - ``` + - severity: info + linters: + - foo + text: 'Example.*' +```
v2 - ```yml - severity: +```yaml +severity: rules: - severity: info - linters: - - foo - text: '(?i)Example.*' - ``` + linters: + - foo + text: '(?i)Example.*' +```
@@ -1458,19 +1447,19 @@ To ignore case, use `(?i)` at the beginning of a regex syntax.
v1 - ```yml - linters: +```yaml +linters: disable-all: true - ``` +```
v2 - ```yml - linters: +```yaml +linters: default: none - ``` +```
@@ -1478,19 +1467,19 @@ To ignore case, use `(?i)` at the beginning of a regex syntax.
v1 - ```yml - linters: +```yaml +linters: enable-all: true - ``` +```
v2 - ```yml - linters: +```yaml +linters: default: all - ``` +```
@@ -1498,10 +1487,9 @@ To ignore case, use `(?i)` at the beginning of a regex syntax. There is no strictly equivalent option in v2 but 2 new options: - To set all "fast" linters as default linters: -```yml +```yaml linters: default: fast ``` From 2518edd4ef6865cdc44531194c11654781a2ce84 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 8 Mar 2025 23:34:14 +0100 Subject: [PATCH 05/15] docs: copy-pastable preset list --- .../src/docs/product/migration-guide-base.mdx | 279 ++++++++++-------- 1 file changed, 153 insertions(+), 126 deletions(-) diff --git a/docs/src/docs/product/migration-guide-base.mdx b/docs/src/docs/product/migration-guide-base.mdx index 5ceb2c1de04a..37e8c7fb860c 100644 --- a/docs/src/docs/product/migration-guide-base.mdx +++ b/docs/src/docs/product/migration-guide-base.mdx @@ -1502,132 +1502,159 @@ The presets have been removed.
v1 Presets - - ๐Ÿ›: bugs - - ๐Ÿ’ฌ: comment - - ๐Ÿงฎ: complexity - - ๐Ÿ’ข: error - - ๐Ÿ’พ: format - - ๐Ÿ”: import - - ๐ŸŽ›๏ธ: metalinter - - ๐Ÿ“ฆ: module - - ๐Ÿ“Š: performance - - ๐Ÿ—‚๏ธ: sql - - ๐ŸŽฉ: style - - ๐Ÿšฆ: test - - ๐Ÿงน: unused - - | | ๐Ÿ› | ๐Ÿ’ฌ | ๐Ÿงฎ | ๐Ÿ’ข | ๐Ÿ’พ | ๐Ÿ” | ๐ŸŽ›๏ธ๏ธ | ๐Ÿ“ฆ | ๐Ÿ“Š | ๐Ÿ—‚๏ธ๏ธ | ๐ŸŽฉ | ๐Ÿšฆ | ๐Ÿงน | - |-----------------------------|----|----|----|----|----|----|------|----|----|------|----|----|----| - | `asasalint` | ๐Ÿ› | | | | | | | | | | | | | - | `asciicheck` | ๐Ÿ› | | | | | | | | | | ๐ŸŽฉ | | | - | `bidichk` | ๐Ÿ› | | | | | | | | | | | | | - | `bodyclose` | ๐Ÿ› | | | | | | | | ๐Ÿ“Š | | | | | - | `canonicalheader` | | | | | | | | | | | ๐ŸŽฉ | | | - | `containedctx` | | | | | | | | | | | ๐ŸŽฉ | | | - | `contextcheck` | ๐Ÿ› | | | | | | | | | | | | | - | `copyloopvar` | | | | | | | | | | | ๐ŸŽฉ | | | - | `cyclop` | | | ๐Ÿงฎ | | | | | | | | | | | - | `decorder` | | | | | | | | | | | ๐ŸŽฉ | | | - | `depguard` | | | | | | ๐Ÿ” | | ๐Ÿ“ฆ | | | ๐ŸŽฉ | | | - | `dogsled` | | | | | | | | | | | ๐ŸŽฉ | | | - | `dupl` | | | | | | | | | | | ๐ŸŽฉ | | | - | `dupword` | | ๐Ÿ’ฌ | | | | | | | | | | | | - | `durationcheck` | ๐Ÿ› | | | | | | | | | | | | | - | `err113` | | | | ๐Ÿ’ข | | | | | | | ๐ŸŽฉ | | | - | `errcheck` | ๐Ÿ› | | | ๐Ÿ’ข | | | | | | | | | | - | `errchkjson` | ๐Ÿ› | | | | | | | | | | | | | - | `errname` | | | | | | | | | | | ๐ŸŽฉ | | | - | `errorlint` | ๐Ÿ› | | | ๐Ÿ’ข | | | | | | | | | | - | `exhaustive` | ๐Ÿ› | | | | | | | | | | | | | - | `exhaustruct` | | | | | | | | | | | ๐ŸŽฉ | ๐Ÿšฆ | | - | `exptostd` | | | | | | | | | | | ๐ŸŽฉ | | | - | `fatcontext` | | | | | | | | | ๐Ÿ“Š | | | | | - | `forbidigo` | | | | | | | | | | | ๐ŸŽฉ | | | - | `forcetypeassert` | | | | | | | | | | | ๐ŸŽฉ | | | - | `funlen` | | | ๐Ÿงฎ | | | | | | | | | | | - | `gci` | | | | | ๐Ÿ’พ | ๐Ÿ” | | | | | | | | - | `ginkgolinter` | | | | | | | | | | | ๐ŸŽฉ | | | - | `gocheckcompilerdirectives` | ๐Ÿ› | | | | | | | | | | | | | - | `gochecknoglobals` | | | | | | | | | | | ๐ŸŽฉ | | | - | `gochecknoinits` | | | | | | | | | | | ๐ŸŽฉ | | | - | `gochecksumtype` | ๐Ÿ› | | | | | | | | | | | | | - | `gocognit` | | | ๐Ÿงฎ | | | | | | | | | | | - | `goconst` | | | | | | | | | | | ๐ŸŽฉ | | | - | `gocritic` | | | | | | | ๐ŸŽ›๏ธ | | | | ๐ŸŽฉ | | | - | `gocyclo` | | | ๐Ÿงฎ | | | | | | | | | | | - | `godot` | | ๐Ÿ’ฌ | | | | | | | | | ๐ŸŽฉ | | | - | `godox` | | ๐Ÿ’ฌ | | | | | | | | | ๐ŸŽฉ | | | - | `gofmt` | | | | | ๐Ÿ’พ | | | | | | | | | - | `gofumpt` | | | | | ๐Ÿ’พ | | | | | | | | | - | `goheader` | | | | | | | | | | | ๐ŸŽฉ | | | - | `goimports` | | | | | ๐Ÿ’พ | ๐Ÿ” | | | | | | | | - | `gomoddirectives` | | | | | | | | ๐Ÿ“ฆ | | | ๐ŸŽฉ | | | - | `gomodguard` | | | | | | ๐Ÿ” | | ๐Ÿ“ฆ | | | ๐ŸŽฉ | | | - | `goprintffuncname` | | | | | | | | | | | ๐ŸŽฉ | | | - | `gosec` | ๐Ÿ› | | | | | | | | | | | | | - | `gosimple` | | | | | | | | | | | ๐ŸŽฉ | | | - | `gosmopolitan` | ๐Ÿ› | | | | | | | | | | | | | - | `govet` | ๐Ÿ› | | | | | | ๐ŸŽ›๏ธ | | | | | | | - | `grouper` | | | | | | | | | | | ๐ŸŽฉ | | | - | `iface` | | | | | | | | | | | ๐ŸŽฉ | | | - | `importas` | | | | | | | | | | | ๐ŸŽฉ | | | - | `inamedparam` | | | | | | | | | | | ๐ŸŽฉ | | | - | `ineffassign` | | | | | | | | | | | | | ๐Ÿงน | - | `interfacebloat` | | | | | | | | | | | ๐ŸŽฉ | | | - | `intrange` | | | | | | | | | | | ๐ŸŽฉ | | | - | `ireturn` | | | | | | | | | | | ๐ŸŽฉ | | | - | `lll` | | | | | | | | | | | ๐ŸŽฉ | | | - | `loggercheck` | ๐Ÿ› | | | | | | | | | | ๐ŸŽฉ | | | - | `maintidx` | | | ๐Ÿงฎ | | | | | | | | | | | - | `makezero` | ๐Ÿ› | | | | | | | | | | ๐ŸŽฉ | | | - | `mirror` | | | | | | | | | | | ๐ŸŽฉ | | | - | `misspell` | | ๐Ÿ’ฌ | | | | | | | | | ๐ŸŽฉ | | | - | `mnd` | | | | | | | | | | | ๐ŸŽฉ | | | - | `musttag` | ๐Ÿ› | | | | | | | | | | ๐ŸŽฉ | | | - | `nakedret` | | | | | | | | | | | ๐ŸŽฉ | | | - | `nestif` | | | ๐Ÿงฎ | | | | | | | | | | | - | `nilerr` | ๐Ÿ› | | | | | | | | | | | | | - | `nilnesserr` | ๐Ÿ› | | | | | | | | | | | | | - | `nilnil` | | | | | | | | | | | ๐ŸŽฉ | | | - | `nlreturn` | | | | | | | | | | | ๐ŸŽฉ | | | - | `noctx` | ๐Ÿ› | | | | | | | | ๐Ÿ“Š | | | | | - | `nolintlint` | | | | | | | | | | | ๐ŸŽฉ | | | - | `nonamedreturns` | | | | | | | | | | | ๐ŸŽฉ | | | - | `nosprintfhostport` | | | | | | | | | | | ๐ŸŽฉ | | | - | `paralleltest` | | | | | | | | | | | ๐ŸŽฉ | ๐Ÿšฆ | | - | `perfsprint` | | | | | | | | | ๐Ÿ“Š | | | | | - | `prealloc` | | | | | | | | | ๐Ÿ“Š | | | | | - | `predeclared` | | | | | | | | | | | ๐ŸŽฉ | | | - | `promlinter` | | | | | | | | | | | ๐ŸŽฉ | | | - | `protogetter` | ๐Ÿ› | | | | | | | | | | | | | - | `reassign` | ๐Ÿ› | | | | | | | | | | | | | - | `recvcheck` | ๐Ÿ› | | | | | | | | | | | | | - | `revive` | | | | | | | ๐ŸŽ›๏ธ | | | | ๐ŸŽฉ | | | - | `rowserrcheck` | ๐Ÿ› | | | | | | | | | ๐Ÿ—‚๏ธ | | | | - | `sloglint` | | | | | | | | | | | ๐ŸŽฉ | | | - | `spancheck` | ๐Ÿ› | | | | | | | | | | | | | - | `sqlclosecheck` | ๐Ÿ› | | | | | | | | | ๐Ÿ—‚๏ธ | | | | - | `staticcheck` | ๐Ÿ› | | | | | | ๐ŸŽ›๏ธ | | | | | | | - | `stylecheck` | | | | | | | | | | | ๐ŸŽฉ | | | - | `tagalign` | | | | | | | | | | | ๐ŸŽฉ | | | - | `tagliatelle` | | | | | | | | | | | ๐ŸŽฉ | | | - | `tenv` | | | | | | | | | | | | ๐Ÿšฆ | | - | `testableexamples` | | | | | | | | | | | | ๐Ÿšฆ | | - | `testifylint` | ๐Ÿ› | | | | | | | | | | | ๐Ÿšฆ | | - | `testpackage` | | | | | | | | | | | ๐ŸŽฉ | ๐Ÿšฆ | | - | `thelper` | | | | | | | | | | | | ๐Ÿšฆ | | - | `tparallel` | | | | | | | | | | | ๐ŸŽฉ | ๐Ÿšฆ | | - | `unconvert` | | | | | | | | | | | ๐ŸŽฉ | | | - | `unparam` | | | | | | | | | | | | | ๐Ÿงน | - | `unused` | | | | | | | | | | | | | ๐Ÿงน | - | `usestdlibvars` | | | | | | | | | | | ๐ŸŽฉ | | | - | `usetesting` | | | | | | | | | | | | ๐Ÿšฆ | | - | `varnamelen` | | | | | | | | | | | ๐ŸŽฉ | | | - | `wastedassign` | | | | | | | | | | | ๐ŸŽฉ | | | - | `whitespace` | | | | | | | | | | | ๐ŸŽฉ | | | - | `wrapcheck` | | | | ๐Ÿ’ข | | | | | | | ๐ŸŽฉ | | | - | `wsl` | | | | | | | | | | | ๐ŸŽฉ | | | - | `zerologlint` | ๐Ÿ› | | | | | | | | | | | | | +- bugs: + - `asasalint` + - `asciicheck` + - `bidichk` + - `bodyclose` + - `contextcheck` + - `durationcheck` + - `errcheck` + - `errchkjson` + - `errorlint` + - `exhaustive` + - `gocheckcompilerdirectives` + - `gochecksumtype` + - `gosec` + - `gosmopolitan` + - `govet` + - `loggercheck` + - `makezero` + - `musttag` + - `nilerr` + - `nilnesserr` + - `noctx` + - `protogetter` + - `reassign` + - `recvcheck` + - `rowserrcheck` + - `spancheck` + - `sqlclosecheck` + - `staticcheck` + - `testifylint` + - `zerologlint` +- comment: + - `dupword` + - `godot` + - `godox` + - `misspell` +- complexity: + - `cyclop` + - `funlen` + - `gocognit` + - `gocyclo` + - `maintidx` + - `nestif` +- error: + - `err113` + - `errcheck` + - `errorlint` + - `wrapcheck` +- format: + - `gci` + - `gofmt` + - `gofumpt` + - `goimports` +- import: + - `depguard` + - `gci` + - `goimports` + - `gomodguard` +- metalinter: + - `gocritic` + - `govet` + - `revive` + - `staticcheck` +- module: + - `depguard` + - `gomoddirectives` + - `gomodguard` +- performance: + - `bodyclose` + - `fatcontext` + - `noctx` + - `perfsprint` + - `prealloc` +- sql: + - `rowserrcheck` + - `sqlclosecheck` +- style: + - `asciicheck` + - `canonicalheader` + - `containedctx` + - `copyloopvar` + - `decorder` + - `depguard` + - `dogsled` + - `dupl` + - `err113` + - `errname` + - `exhaustruct` + - `exptostd` + - `forbidigo` + - `forcetypeassert` + - `ginkgolinter` + - `gochecknoglobals` + - `gochecknoinits` + - `goconst` + - `gocritic` + - `godot` + - `godox` + - `goheader` + - `gomoddirectives` + - `gomodguard` + - `goprintffuncname` + - `gosimple` + - `grouper` + - `iface` + - `importas` + - `inamedparam` + - `interfacebloat` + - `intrange` + - `ireturn` + - `lll` + - `loggercheck` + - `makezero` + - `mirror` + - `misspell` + - `mnd` + - `musttag` + - `nakedret` + - `nilnil` + - `nlreturn` + - `nolintlint` + - `nonamedreturns` + - `nosprintfhostport` + - `paralleltest` + - `predeclared` + - `promlinter` + - `revive` + - `sloglint` + - `stylecheck` + - `tagalign` + - `tagliatelle` + - `testpackage` + - `tparallel` + - `unconvert` + - `usestdlibvars` + - `varnamelen` + - `wastedassign` + - `whitespace` + - `wrapcheck` + - `wsl` +- test: + - `exhaustruct` + - `paralleltest` + - `testableexamples` + - `testifylint` + - `testpackage` + - `thelper` + - `tparallel` + - `usetesting` +- unused: + - `ineffassign` + - `unparam` + - `unused`
From e280408fec4ddbef90fc134feb16706830025180 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 8 Mar 2025 23:48:32 +0100 Subject: [PATCH 06/15] docs: consistent quotes --- .../src/docs/product/migration-guide-base.mdx | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/docs/src/docs/product/migration-guide-base.mdx b/docs/src/docs/product/migration-guide-base.mdx index 37e8c7fb860c..9313c02f0dcb 100644 --- a/docs/src/docs/product/migration-guide-base.mdx +++ b/docs/src/docs/product/migration-guide-base.mdx @@ -82,7 +82,7 @@ issues: linters: exclusions: rules: - - path: (.+)\.go$ + - path: '(.+)\.go$' text: (?i)abcdef ``` @@ -145,7 +145,7 @@ linters: ```yaml issues: exclude-files: - - ".*\\.my\\.go$" + - '.*\.my\.go$' - lib/bad.go ``` @@ -157,7 +157,7 @@ issues: linters: exclusions: paths: - - .*\.my\.go$ + - '.*\.my\.go$' - lib/bad.go ``` @@ -214,13 +214,13 @@ linters: ```yaml issues: exclude-rules: - - path: _test\.go + - path: '_test\.go' linters: - gocyclo - errcheck - dupl - gosec - - path-except: _test\.go + - path-except: '_test\.go' linters: - staticcheck - path: internal/hmac/ @@ -243,13 +243,13 @@ issues: linters: exclusions: rules: - - path: _test\.go + - path: '_test\.go' linters: - dupl - errcheck - gocyclo - gosec - - path-except: _test\.go + - path-except: '_test\.go' linters: - staticcheck - path: internal/hmac/ @@ -309,7 +309,7 @@ issues: linters: exclusions: rules: - - path: (.+)\.go$ + - path: '(.+)\.go$' text: abcdef ``` @@ -399,7 +399,7 @@ linters-settings: linters: exclusions: rules: - - path: (.+)_test\.go + - path: '(.+)_test\.go' linters: - asasalint ``` @@ -449,7 +449,7 @@ linters-settings: linters: exclusions: rules: - - path: (.+)_test\.go + - path: '(.+)_test\.go' linters: - cyclop ``` @@ -477,9 +477,9 @@ linters: settings: errcheck: exclude-functions: - - example.ReadFile - - example.Copy(*bytes.Buffer) - - example.Copy(os.Stdout) + - 'example.ReadFile' + - 'example.Copy(*bytes.Buffer)' + - 'example.Copy(os.Stdout)' ```
@@ -506,9 +506,9 @@ linters: settings: errcheck: exclude-functions: - - example.ReadFile - - example.Copy(*bytes.Buffer) - - example.Copy(os.Stdout) + - 'example.ReadFile' + - 'example.Copy(*bytes.Buffer)' + - 'example.Copy(os.Stdout)' ``` @@ -543,7 +543,7 @@ linters: linters-settings: forbidigo: forbid: - - p: ^fmt\.Print.*$ + - p: '^fmt\.Print.*$' msg: Do not commit print statements. ``` @@ -556,7 +556,7 @@ linters: settings: forbidigo: forbid: - - pattern: ^fmt\.Print.*$ + - pattern: '^fmt\.Print.*$' msg: Do not commit print statements. ``` @@ -570,8 +570,8 @@ linters: linters-settings: forbidigo: forbid: - - ^print(ln)?$ - - ^spew\.(ConfigState\.)?Dump$ + - '^print(ln)?$' + - '^spew\.(ConfigState\.)?Dump$' ``` @@ -583,8 +583,8 @@ linters: settings: forbidigo: forbid: - - pattern: ^print(ln)?$ - - pattern: ^spew\.(ConfigState\.)?Dump$ + - pattern: '^print(ln)?$' + - pattern: '^spew\.(ConfigState\.)?Dump$' ``` @@ -659,7 +659,7 @@ linters-settings: linters: exclusions: rules: - - path: (.+)_test\.go + - path: '(.+)_test\.go' linters: - goconst ``` @@ -825,7 +825,7 @@ linters-settings: linters: exclusions: rules: - - path: (.+)_test\.go + - path: '(.+)_test\.go' linters: - gosmopolitan ``` @@ -1091,7 +1091,7 @@ Removed. linters-settings: wrapcheck: ignoreInterfaceRegexps: - - ^(?i)c(?-i)ach(ing|e) + - '^(?i)c(?-i)ach(ing|e)' ``` @@ -1103,7 +1103,7 @@ linters: settings: wrapcheck: ignore-interface-regexps: - - ^(?i)c(?-i)ach(ing|e) + - '^(?i)c(?-i)ach(ing|e)' ``` @@ -1116,7 +1116,7 @@ linters: linters-settings: wrapcheck: ignorePackageGlobs: - - encoding/* + - 'encoding/*' ``` @@ -1128,7 +1128,7 @@ linters: settings: wrapcheck: ignore-package-globs: - - encoding/* + - 'encoding/*' ``` @@ -1141,7 +1141,7 @@ linters: linters-settings: wrapcheck: ignoreSigRegexps: - - \.New.*Error\( + - '\.New.*Error\(' ``` @@ -1153,7 +1153,7 @@ linters: settings: wrapcheck: ignore-sig-regexps: - - \.New.*Error\( + - '\.New.*Error\(' ``` @@ -1166,7 +1166,7 @@ linters: linters-settings: wrapcheck: ignoreSigs: - - .Errorf( + - '.Errorf(' ``` @@ -1178,7 +1178,7 @@ linters: settings: wrapcheck: ignore-sigs: - - .Errorf( + - '.Errorf(' ``` @@ -1207,7 +1207,7 @@ output: json: path: stdout checkstyle: - path: report.xml + path: 'report.xml' ``` @@ -1222,7 +1222,7 @@ output: - format: json path: stderr - format: checkstyle - path: report.xml + path: 'report.xml' - format: colored-line-number ``` @@ -1239,7 +1239,7 @@ output: json: path: stdout checkstyle: - path: report.xml + path: 'report.xml' ``` @@ -1364,7 +1364,7 @@ Deprecated since v1.57.0. ```yaml run: skip-files: - - ".*\\.my\\.go$" + - '.*\.my\.go$' - lib/bad.go ``` @@ -1376,7 +1376,7 @@ run: linters: exclusions: paths: - - ".*\\.my\\.go$" + - '.*\.my\.go$' - lib/bad.go ``` From 8732caab0cb4f938d4012d21ec3b9c284b9c5f03 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Wed, 12 Mar 2025 15:42:52 +0200 Subject: [PATCH 07/15] Integrate with base: improve grammar --- docs/src/docs/product/migration-guide.mdx | 356 ++++------------------ 1 file changed, 55 insertions(+), 301 deletions(-) diff --git a/docs/src/docs/product/migration-guide.mdx b/docs/src/docs/product/migration-guide.mdx index a0c09c96be69..8e22c14526df 100644 --- a/docs/src/docs/product/migration-guide.mdx +++ b/docs/src/docs/product/migration-guide.mdx @@ -2,369 +2,123 @@ title: Migration guide --- -## Migrating configuration from v1 to v2 +## Command `migrate` -Golangci-lint v2 has slightly different configuration options than v1. -Some options were renamed, some were moved, some were split, and some were removed. -Here is a guide how to migrate your v1 configuration. +You can use `golangci-lint` to migrate your configuration with the `migrate` command: -You can use `golangci-lint` itself to migrate your configuration automatically through the `migrate` command: - -```sh +```bash golangci-lint migrate ``` -In case you want to do it manually, here is a list of changes. - ---- - -### `linters` configuration - -#### Replaced +Be aware that **comments inside a configuration file are not migrated.** You need to add them manually after the migration. -1. `linters.disable-all` replaced with `linters.default: none`. +**Deprecated options from v1 or unknown fields are not migrated.** -
-v1 +The migration file format is based on the extension of the [configuration file](/usage/configuration/#config-file). +The format can be overridden by using the `--format` flag: -```yaml -linters: - disable-all: true +```bash +golangci-lint migrate --format json ``` -
+Before the migration, the previous configuration file is copied and saved to a file named `.bck.`. -
-v2 +By default, before the migration process, the configuration file is validated against the JSON Schema of configuration v1. +If you want to skip this validation, you can use the `--skip-validation` flag: -```yaml -linters: - default: none +```bash +golangci-lint migrate --skip-validation ``` -
+The `migrate` command enforces the following default values: -See [golangci-lint#5474](https://github.com/golangci/golangci-lint/pull/5475) for more details. +- `run.timeout`: the existing value is ignored because, in v2, there is no timeout by default. +- `issues.show-stats`: the existing value is ignored because, in v2, stats are enabled by default. +- `run.concurrency`: if the existing value was `0`, it is removed as `0` is the new default. +- `run.relative-path-mode`: if the existing value was `cfg`, it is removed as `cfg` is the new default. -2. `linters.enable-all` replaced with `linters.default: all`. +`issues.exclude-generated` has a new default value (v1 `lax`, v2 `strict`), so this field will be added during the migration to maintain the previous behavior. -
-v1 +`issues.exclude-dirs-use-default` has been removed, so it is converted to `linters.exclusions.paths` and, if needed, `formatters.exclusions.paths`. -```yaml -linters: - enable-all: true -``` +Other fields explicitly defined in the configuration file are migrated even if the value is the same as the default value. -
+```txt +Migrate configuration file from v1 to v2 -
-v2 +Usage: + golangci-lint migrate [flags] -```yaml -linters: - default: all -``` +Flags: + -c, --config PATH Read config from file path PATH + --no-config Don't read config file + --format string Output file format. + By default, the format of the input configuration file is used. + It can be 'yml', 'yaml', 'toml', or 'json'. + --skip-validation Skip validation of the configuration file against the JSON Schema for v1. -
- -See [golangci-lint#5474](https://github.com/golangci/golangci-lint/pull/5475) for more details. - ---- - -### `linters-settings` configuration - -#### Split +Global Flags: + -h, --help Help for a command -1. `linters-settings` section split to `linters.settings` and `formatters.settings`. - -Most linters settings are now in the `linters.settings` section. -Settings for `gci`, `gofmt`, `gofumpt`, `goimports` are moved to the `formatters.settings` section. - -
-v1 - -```yaml -linters-settings: - gofmt: - simplify: true - govet: - disable-all: true ``` -
- -
-v2 - -```yaml -linters: - settings: - govet: - disable-all: true - -formatters: - settings: - gofmt: - simplify: true -``` - -
- -See [golangci-lint#5474](https://github.com/golangci/golangci-lint/pull/5475) for more details. +## Changes ---- - -### `issues` configuration +### `issues` -#### Removed +#### `issues.exclude-case-sensitive` -1. `issues.exclude-case-sensitive` option. +`issues.exclude`, `issues.exclude-rules.text`, and `issues.exclude-rules.source` are case-sensitive by default. -`issues.exclude` and `issues.exclude-rules` are case sensitive by default. To ignore case, use `(?i)` at the beginning of a regex syntax.
-v1 + v1 ```yaml issues: exclude-case-sensitive: false - exclude: - - 'abcdef' + exclude: + - 'abcdef' ```
-v2 - -```yaml -issues: - exclude: - - '(?i)abcdef' -``` - -
- -See [golangci-lint#5451](https://github.com/golangci/golangci-lint/pull/5451) for more details. - -2. `issues.exclude-dirs-use-default` option. - -
-v1 + v2 ```yaml -issues: - exclude-dirs-use-default: false -``` - -
- -
-v2 - -TODO - -
- - -See [golangci-lint#5451](https://github.com/golangci/golangci-lint/pull/5451) for more details. - -#### Replaced - -1. `exclude-dirs` and `exclude-files` replaced with `exclusions.paths`. - -
-v1 - -```yaml -issues: - exclude-dirs: - - src/external_libs - - autogenerated_by_my_lib - - exclude-files: - - ".*\\.my\\.go$" - - lib/bad.go -``` - -
- -
-v2 - -```yaml -issues: +linters: exclusions: - paths: - - src/external_libs - - autogenerated_by_my_lib - - ".*\\.my\\.go$" - - lib/bad.go + rules: + - path: '(.+)\.go$' + text: (?i)abcdef ```
-2. `issues.exclude-generated-strict` and `issues.exclude-generated` replaced with `linters.exclusions.generated`. +#### `issues.exclude-dirs-use-default`
-v1 + v1 ```yaml issues: - exclude-generated-strict: true - exclude-generated: strict + exclude-dirs-use-default: true ```
-v2 + v2 ```yaml linters: exclusions: - generated: strict -``` - -
- ---- - -### `output` configuration - -#### Replaced - -1. `output.format` replaced with `output.formats`. - -Deprecated since [v1.57.0](https://golangci-lint.run/product/changelog/#v1570). - -
-v1 - -```yaml -output: - format: "checkstyle:report.xml,json:stdout,colored-line-number" -``` - -
- -
-v2 - -```yaml -output: - formats: - - format: checkstyle - path: report.xml - - format: json - path: stdout - - format: colored-line-number -``` - -
- -See [golangci-lint#4521](https://github.com/golangci/golangci-lint/pull/4521) for more details. - -#### Changed - -1. `output.show-stats` is `true` by default. - -
-v1 - -```yaml -output: - # show-stats is not present -``` - -
- -
-v2 - -```yaml -output: - show-stats: true -``` - -
- -See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details. - ---- - -### `run` configuration - -#### Changed - -1. `run.go` fallback to `1.23`. - -In v1, `run.go` fallback to `1.17`. - -See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details. - -2. `run.timeout` is `0` (disabled) by default. - -TODO: see https://github.com/golangci/golangci-lint/pull/5506#discussion_r1984001235 - -In v1, `run.timeout` was `1m` by default. - -
-v1 - -```yaml -run: - # timeout is not present -``` - -
- -
-v2 - -```yaml -run: - timeout: 1m -``` - -
- -See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details. - -3. `run.concurrency` set to match Linux container CPU quota by default. - -In v1, `run.concurrency` was set to the number of logical CPUs in the machine. - -See [golangci-lint#5470](https://github.com/golangci/golangci-lint/pull/5470) for more details. - ---- - -### `severity` configuration - -#### Renamed - -1. `severity.default-severity` renamed to `severity.default`. - -
-v1 - -```yaml -severity: - default-severity: error -``` - -
- -
-v2 - -```yaml -severity: - default: error + paths: + - third_party$ + - builtin$ + - examples$ ```
- -See [golangci-lint#5462](https://github.com/golangci/golangci-lint/pull/5462) for more details. From 33bdee4daa6961aeca15d3e5410183921140ef0d Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Thu, 13 Mar 2025 00:30:39 +0200 Subject: [PATCH 08/15] Add rest of the changes --- docs/src/docs/product/migration-guide.mdx | 1649 ++++++++++++++++++++- 1 file changed, 1642 insertions(+), 7 deletions(-) diff --git a/docs/src/docs/product/migration-guide.mdx b/docs/src/docs/product/migration-guide.mdx index 8e22c14526df..78b6f8656dfa 100644 --- a/docs/src/docs/product/migration-guide.mdx +++ b/docs/src/docs/product/migration-guide.mdx @@ -68,39 +68,45 @@ Global Flags: #### `issues.exclude-case-sensitive` +This property has been removed. + `issues.exclude`, `issues.exclude-rules.text`, and `issues.exclude-rules.source` are case-sensitive by default. To ignore case, use `(?i)` at the beginning of a regex syntax.
- v1 +v1 ```yaml issues: exclude-case-sensitive: false - exclude: - - 'abcdef' + exclude: + - 'abcdef' ```
- v2 +v2 ```yaml linters: exclusions: rules: - - path: '(.+)\.go$' - text: (?i)abcdef + - path: '(.+)\.go$' + text: (?i)abcdef ```
#### `issues.exclude-dirs-use-default` +This property has been removed. + +Use `linters.exclusions.paths` and `formatters.exclusions.paths` to exclude directories. +
- v1 +v1 ```yaml issues: @@ -122,3 +128,1632 @@ linters: ```
+ +#### `issues.exclude-dirs` + +This property has been replaced with `linters.exclusions.paths` and `formatters.exclusions.paths`. + +
+v1 + +```yaml +issues: + exclude-dirs: + - src/external_libs + - autogenerated_by_my_lib +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + paths: + - src/external_libs + - autogenerated_by_my_lib +``` + +
+ +#### `issues.exclude-files` + +This property has been replaced with `linters.exclusions.paths` and `formatters.exclusions.paths`. + +
+v1 + +```yaml +issues: + exclude-files: + - '.*\.my\.go$' + - lib/bad.go +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + paths: + - '.*\.my\.go$' + - lib/bad.go +``` + +
+ +#### `issues.exclude-generated-strict` + +This property has been deprecated since v1.59.0 and has been replaced with `linters.exclusions.generated: strict`. + +
+v1 + +```yaml +linters: + exclude-generated-strict: true +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + generated: strict +``` + +
+ +#### `issues.exclude-generated` + +This property has been replaced with `linters.exclusions.generated`. + +
+v1 + +```yaml +linters: + exclude-generated: lax +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + generated: lax +``` + +
+ +#### `issues.exclude-rules` + +This property has been replaced with `linters.exclusions.rules`. + +
+v1 + +```yaml +issues: + exclude-rules: + - path: '_test\.go' + linters: + - gocyclo + - errcheck + - dupl + - gosec + - path-except: '_test\.go' + linters: + - staticcheck + - path: internal/hmac/ + text: "weak cryptographic primitive" + linters: + - gosec + - linters: + - staticcheck + text: "SA9003:" + - linters: + - err113 + source: "foo" +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + rules: + - path: '_test\.go' + linters: + - dupl + - errcheck + - gocyclo + - gosec + - path-except: '_test\.go' + linters: + - staticcheck + - path: internal/hmac/ + text: weak cryptographic primitive + linters: + - gosec + - text: 'SA9003:' + linters: + - staticcheck + - source: foo + linters: + - err113 + ``` + +
+ + +#### `issues.exclude-use-default` + +This property has been replaced with `linters.exclusions.presets`. + +
+v1 + +```yaml +issues: + exclude-use-default: true +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + presets: + - comments + - common-false-positives + - legacy + - std-error-handling +``` + +
+ +#### `issues.exclude` + +This property has been replaced with `linters.exclusions.rules`. + +
+v1 + +```yaml +issues: + exclude: + - abcdef +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + rules: + - path: '(.+)\.go$' + text: abcdef +``` + +
+ +#### `issues.include` + +This property has been replaced with `linters.exclusions.presets`. + +
+v1 + +```yaml +issues: + include: + - EXC0014 + - EXC0015 +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + presets: + - common-false-positives + - legacy + - std-error-handling +``` + +
+ +### `linters-settings` + +`linters-settings` section has been split to `linters.settings` and `formatters.settings`. + +Settings for `gci`, `gofmt`, `gofumpt`, `goimports` are moved to the `formatters.settings` section. + +
+v1 + +```yaml +linters-settings: + govet: + disable-all: true + gofmt: + simplify: false +``` + +
+ +
+v2 + +```yaml +linters: + settings: + govet: + disable-all: true + +formatters: + settings: + gofmt: + simplify: false +``` + +
+ +#### `linters-settings.asasalint.ignore-test` + +This option has been removed. + +To ignore test files, use `linters.exclusions.rules`. + +
+v1 + +```yaml +linters-settings: + asasalint: + ignore-test: true +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + rules: + - path: '(.+)_test\.go' + linters: + - asasalint +``` + +
+ +#### `linters-settings.copyloopvar.ignore-alias` + +This option has been deprecated since v1.58.0 and has been replaced with `linters.settings.copyloopvar.check-alias`. + +
+v1 + +```yaml +linters-settings: + copyloopvar: + ignore-alias: false +``` + +
+ +
+v2 + +```yaml +linters: + settings: + copyloopvar: + check-alias: true +``` + +
+ +#### `linters-settings.cyclop.skip-tests` + +This option has been removed. + +To ignore test files, use `linters.exclusions.rules`. + +
+v1 + +```yaml +linters-settings: + cyclop: + skip-test: true +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + rules: + - path: '(.+)_test\.go' + linters: + - cyclop +``` + +
+ +#### `linters-settings.errcheck.exclude` + +This option has been deprecated since v1.42.0. + +To exclude functions, use `linters.settings.errcheck.exclude-functions` instead. + +
+v1 + +```yaml +linters-settings: + errcheck: + exclude: ./errcheck_excludes.txt +``` + +
+ +
+v2 + +```yaml +linters: + settings: + errcheck: + exclude-functions: + - io.ReadFile + - io.Copy(*bytes.Buffer) + - io.Copy(os.Stdout) +``` + +
+ +#### `linters-settings.errcheck.ignore` + +This option has been deprecated since v1.13.0. + +To exclude functions, use `linters.settings.errcheck.exclude-functions` instead. + +
+v1 + +```yaml +linters-settings: + errcheck: + ignore: 'io:.*' + +``` + +
+ +
+v2 + +```yaml +linters: + settings: + errcheck: + exclude-functions: + - 'io.ReadFile' + - 'io.Copy(*bytes.Buffer)' + - 'io.Copy(os.Stdout)' +``` + +
+ +#### `linters-settings.exhaustive.check-generated` + +This option has been removed. + +To analyze generated files use `linters.exclusions.generated`. + +
+v1 + +```yaml +linters-settings: + exhaustive: + check-generated: true +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + generated: disable +``` + +
+ +#### `linters-settings.forbidigo.forbid[].p` + +This field has been replaced with `linters-settings.forbidigo.forbid[].pattern`. + +
+v1 + +```yaml +linters-settings: + forbidigo: + forbid: + - p: '^fmt\.Print.*$' + msg: Do not commit print statements. +``` + +
+ +
+v2 + +```yaml +linters: + settings: + forbidigo: + forbid: + - pattern: '^fmt\.Print.*$' + msg: Do not commit print statements. +``` + +
+ +#### `linters-settings.forbidigo.forbid[].rawPattern` + +The `pattern` has become mandatory for the `forbid` field. + +
+v1 + +```yaml +linters-settings: + forbidigo: + forbid: + - '^print(ln)?$' + - '^spew\.(ConfigState\.)?Dump$' +``` + +
+ +
+v2 + +```yaml +linters: + settings: + forbidigo: + forbid: + - pattern: '^print(ln)?$' + - pattern: '^spew\.(ConfigState\.)?Dump$' +``` + +
+ +#### `linters-settings.gci.local-prefixes` + +This option has been deprecated since v1.44.0 and has been removed. + +Use `linters.settings.gci.sections` instead. + +
+v1 + +```yaml +linters-settings: + gci: + local-prefixes: 'github.com/example/pkg' +``` + +
+ +
+v2 + +```yaml +linters: + settings: + gci: + sections: + - standard + - default + - prefix(github.com/example/pkg) +``` + +
+ +#### `linters-settings.gci.skip-generated` + +This option has been removed. + +To analyze generated files use `linters.exclusions.generated`. + +
+v1 + +```yaml +linters: + settings: + gci: + skip-generated: false +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + generated: disable +``` + +
+ +#### `linters-settings.goconst.ignore-tests` + +This option has been removed. + +To ignore test files, use `linters.exclusions.rules`. + +
+v1 + +```yaml +linters-settings: + goconst: + ignore-tests: true +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + rules: + - path: '(.+)_test\.go' + linters: + - goconst +``` + +
+ +#### `linters-settings.govet.check-shadowing` + +This option has been deprecated since v1.57.0 and has been removed. + +Use `linters.settings.govet.enable: shadow` instead. + +
+v1 + +```yaml +linters-settings: + govet: + check-shadowing: true +``` + +
+ +
+v2 + +```yaml +linters: + settings: + govet: + enable: + - shadow +``` + +
+ +#### `linters-settings.misspell.ignore-words` + +This option has been replaced with `linters.settings.misspell.ignore-rules`. + +
+v1 + +```yaml +linters-settings: + misspell: + ignore-words: + - foo +``` + +
+ +
+v2 + +```yaml +linters: + settings: + misspell: + ignore-rules: + - foo +``` + +
+ +#### `linters-settings.predeclared.ignore` + +This string option has been replaced with the slice option `linters.settings.predeclared.ignore`. + +
+v1 + +```yaml +linters-settings: + predeclared: + ignore: "new,int" +``` + +
+ +
+v2 + +```yaml +linters: + settings: + predeclared: + ignore: + - new + - int +``` + +
+ +#### `linters-settings.predeclared.q` + +This option has been replaced with `linters.settings.predeclared.qualified-name`. + +
+v1 + +```yaml +linters-settings: + predeclared: + q: true +``` + +
+ +
+v2 + +```yaml +linters: + settings: + predeclared: + qualified-name: true +``` + +
+ +#### `linters-settings.revive.ignore-generated-header` + +This option has been removed. + +Use `linters.exclusions.generated` instead. + +
+v1 + +```yaml +linters-settings: + revive: + ignore-generated-header: true +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + generated: strict +``` + +
+ +#### `linters-settings.sloglint.context-only` + +This option has been deprecated since v1.58.0 and has been replaced with `linters.settings.sloglint.context`. + +
+v1 + +```yaml +linters-settings: + sloglint: + context-only: true +``` + +
+ +
+v2 + +```yaml +linters: + settings: + sloglint: + context: all +``` + +
+ +#### `linters-settings.staticcheck.go` + +This option has been deprecated since v1.47.0 and has been removed. + +Use `run.go` instead. + +
+v1 + +```yaml +linters-settings: + staticcheck: + go: '1.22' +``` + +
+ +
+v2 + +```yaml +run: + go: '1.22' +``` + +
+ +#### `linters-settings.unused.exported-is-used` + +This option has been deprecated since v1.60.0 and has been removed. + +
+v1 + +```yaml +linters-settings: + unused: + exported-is-used: true +``` + +
+ +
+v2 + +```yaml +# Removed +``` + +
+ +#### `linters-settings.usestdlibvars.os-dev-null` + +This option has been deprecated since v1.51.0 and has been removed. + +
+v1 + +```yaml +linters-settings: + usestdlibvars: + os-dev-null: true +``` + +
+ +
+v2 + +```yaml +# Removed +``` + +
+ +#### `linters-settings.usestdlibvars.syslog-priority` + +This option has been deprecated since v1.51.0 and has been removed. + +
+v1 + +```yaml +linters-settings: + usestdlibvars: + syslog-priority: true +``` + +
+ +
+v2 + +```yaml +# Removed +``` + +
+ +#### `linters-settings.wrapcheck.ignoreInterfaceRegexps` + +This option has been replaced with `linters.settings.wrapcheck.ignore-interface-regexps`. + +
+v1 + +```yaml +linters-settings: + wrapcheck: + ignoreInterfaceRegexps: + - '^(?i)c(?-i)ach(ing|e)' +``` + +
+ +
+v2 + +```yaml +linters: + settings: + wrapcheck: + ignore-interface-regexps: + - '^(?i)c(?-i)ach(ing|e)' +``` + +
+ +#### `linters-settings.wrapcheck.ignorePackageGlobs` + +This option has been replaced with `linters.settings.wrapcheck.ignore-package-globs`. + +
+v1 + +```yaml +linters-settings: + wrapcheck: + ignorePackageGlobs: + - 'encoding/*' +``` + +
+ +
+v2 + +```yaml +linters: + settings: + wrapcheck: + ignore-package-globs: + - 'encoding/*' +``` + +
+ +#### `linters-settings.wrapcheck.ignoreSigRegexps` + +This option has been replaced with `linters.settings.wrapcheck.ignore-sig-regexps`. + +
+v1 + +```yaml + linters-settings: + wrapcheck: + ignoreSigRegexps: + - '\.New.*Error\(' +``` + +
+ +
+v2 + +```yaml +linters: + settings: + wrapcheck: + ignore-sig-regexps: + - '\.New.*Error\(' +``` + +
+ +#### `linters-settings.wrapcheck.ignoreSigs` + +This option has been replaced with `linters.settings.wrapcheck.ignore-sigs`. + +
+v1 + +```yaml +linters-settings: + wrapcheck: + ignoreSigs: + - '.Errorf(' +``` + +
+ +
+v2 + +```yaml +linters: + settings: + wrapcheck: + ignore-sigs: + - '.Errorf(' +``` + +
+ +### `output` + +#### `output.format` + +This property has been deprecated since v1.57.0 and has been replaced with `output.formats`. + +
+v1 + +```yaml +output: + format: 'checkstyle:report.xml,json:stdout,colored-line-number' +``` + +
+ +
+v2 + +```yaml +output: + formats: + text: + path: stdout + color: true + json: + path: stdout + checkstyle: + path: 'report.xml' +``` + +
+ +#### `output.formats[].format: name` + +The property `output.formats[].format` has been replaced with `output.formats[].formatName`. + +The formats `colored-line-number`, `colored-tab` has been removed. Use `output.formats[].text.colors: true` and `output.formats[].tab.colors: true` instead. + +
+v1 + +```yaml +output: + formats: + - format: json + path: stderr + - format: checkstyle + path: 'report.xml' + - format: colored-line-number +``` + +
+ +
+v2 + +```yaml +output: + formats: + json: + path: stderr + checkstyle: + path: 'report.xml' + text: + path: stdout + colors: true +``` + +
+ +#### `output.show-stats` + +This property is `true` by default. + +#### `output.sort-order` + +This property has new default: [`linter`, `file`] instead of [`file`]. + +#### `output.sort-results` + +The property has been removed. The output results are always sorted. + +#### `output.uniq-by-line` + +This property has been deprecated since v1.63.0 and has been replaced by `issues.uniq-by-line`. + +
+v1 + +```yaml +output: + uniq-by-line: true +``` + +
+ +
+v2 + +```yaml +issues: + uniq-by-line: true +``` + +
+ +### `run` + +#### `run.concurrency` + +This property value set to match Linux container CPU quota by default and fallback on the number of logical CPUs in the machine. + +#### `run.show-stats` + +This property has been deprecated since v1.57.0 and replaced by `output.show-stats`. + +
+v1 + +```yaml +run: + show-stats: true +``` + +
+ +
+v2 + +```yaml +output: + show-stats: true +``` + +
+ +#### `run.skip-dirs-use-default` + +This property has been deprecated since v1.57.0 and replaced by `issues.exclude-dirs-use-default`. + +
+v1 + +```yaml +run: + skip-dirs-use-default: false +``` + +
+ +
+v2 + +```yaml +issues: + exclude-dirs-use-default: false +``` + +
+ +#### `run.skip-dirs` + +This property has been deprecated since v1.57.0 and has been removed. + +Use `linters.exclusions.paths` and `formatters.exclusions.paths` to exclude directories. + +
+v1 + +```yaml +run: + skip-dirs: + - src/external_libs + - autogenerated_by_my_lib +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + paths: + - src/external_libs + - autogenerated_by_my_lib +``` + +
+ +#### `run.skip-files` + +This property has been deprecated since v1.57.0 and has been removed. + +Use `linters.exclusions.paths` and `formatters.exclusions.paths` to exclude files. + +
+v1 + +```yaml +run: + skip-files: + - '.*\.my\.go$' + - lib/bad.go +``` + +
+ +
+v2 + +```yaml +linters: + exclusions: + paths: + - '.*\.my\.go$' + - lib/bad.go +``` + +
+ +#### `run.timeout` + +This property value is disabled by default (`0`). + +### `severity` + +#### `severity.default-severity` + +This property has been replaced with `severity.default`. + +
+v1 + +```yaml +severity: + default-severity: error +``` + +
+ +
+v2 + +```yaml +severity: + default: error +``` + +
+ +#### `severity.rules.case-sensitive` + +`severity.rules.text` and `severity.rules.source` are case-sensitive by default. + +To ignore case, use `(?i)` at the beginning of a regex syntax. + +
+v1 + +```yaml +severity: + case-sensitive: true + rules: + - severity: info + linters: + - foo + text: 'Example.*' +``` + +
+ +
+v2 + +```yaml +severity: + rules: + - severity: info + linters: + - foo + text: '(?i)Example.*' +``` + +
+ +### `linters` + +#### `linters.disable-all` + +This property has been replaced with `linters.default: none`. + +
+v1 + +```yaml +linters: + disable-all: true +``` + +
+ +
+v2 + +```yaml +linters: + default: none +``` + +
+ +#### `linters.enable-all` + +This property has been replaced with `linters.default: all`. + +
+v1 + +```yaml +linters: + enable-all: true +``` + +
+ +
+v2 + +```yaml +linters: + default: all +``` + +
+ +#### `linters.fast` + +This property has been replaced with `linters.default: fast`. It is not a strictly equivalent. + +
+v1 + +```yaml +linters: + fast: true +``` + +
+ +
+v2 + +```yaml +linters: + default: fast +``` + +
+ +Also, the new flag option `--fast-only` filters enabled linters to keep only "fast" linters. + +#### `linters.presets` + +This property have been removed. + +
+v1 + +Presets: + +- bugs: + - `asasalint` + - `asciicheck` + - `bidichk` + - `bodyclose` + - `contextcheck` + - `durationcheck` + - `errcheck` + - `errchkjson` + - `errorlint` + - `exhaustive` + - `gocheckcompilerdirectives` + - `gochecksumtype` + - `gosec` + - `gosmopolitan` + - `govet` + - `loggercheck` + - `makezero` + - `musttag` + - `nilerr` + - `nilnesserr` + - `noctx` + - `protogetter` + - `reassign` + - `recvcheck` + - `rowserrcheck` + - `spancheck` + - `sqlclosecheck` + - `staticcheck` + - `testifylint` + - `zerologlint` +- comment: + - `dupword` + - `godot` + - `godox` + - `misspell` +- complexity: + - `cyclop` + - `funlen` + - `gocognit` + - `gocyclo` + - `maintidx` + - `nestif` +- error: + - `err113` + - `errcheck` + - `errorlint` + - `wrapcheck` +- format: + - `gci` + - `gofmt` + - `gofumpt` + - `goimports` +- import: + - `depguard` + - `gci` + - `goimports` + - `gomodguard` +- metalinter: + - `gocritic` + - `govet` + - `revive` + - `staticcheck` +- module: + - `depguard` + - `gomoddirectives` + - `gomodguard` +- performance: + - `bodyclose` + - `fatcontext` + - `noctx` + - `perfsprint` + - `prealloc` +- sql: + - `rowserrcheck` + - `sqlclosecheck` +- style: + - `asciicheck` + - `canonicalheader` + - `containedctx` + - `copyloopvar` + - `decorder` + - `depguard` + - `dogsled` + - `dupl` + - `err113` + - `errname` + - `exhaustruct` + - `exptostd` + - `forbidigo` + - `forcetypeassert` + - `ginkgolinter` + - `gochecknoglobals` + - `gochecknoinits` + - `goconst` + - `gocritic` + - `godot` + - `godox` + - `goheader` + - `gomoddirectives` + - `gomodguard` + - `goprintffuncname` + - `gosimple` + - `grouper` + - `iface` + - `importas` + - `inamedparam` + - `interfacebloat` + - `intrange` + - `ireturn` + - `lll` + - `loggercheck` + - `makezero` + - `mirror` + - `misspell` + - `mnd` + - `musttag` + - `nakedret` + - `nilnil` + - `nlreturn` + - `nolintlint` + - `nonamedreturns` + - `nosprintfhostport` + - `paralleltest` + - `predeclared` + - `promlinter` + - `revive` + - `sloglint` + - `stylecheck` + - `tagalign` + - `tagliatelle` + - `testpackage` + - `tparallel` + - `unconvert` + - `usestdlibvars` + - `varnamelen` + - `wastedassign` + - `whitespace` + - `wrapcheck` + - `wsl` +- test: + - `exhaustruct` + - `paralleltest` + - `testableexamples` + - `testifylint` + - `testpackage` + - `thelper` + - `tparallel` + - `usetesting` +- unused: + - `ineffassign` + - `unparam` + - `unused` + +
+ +
+v2 + +```yaml +# Removed +``` + +
+ +### Alternative Linter Names + +The alternative linters has been removed. + +| Alt Name V1 | V2 Name | +|-------------|---------------| +| `gas` | `gosec` | +| `goerr113` | `err113` | +| `gomnd` | `mnd` | +| `logrlint` | `loggercheck` | +| `megacheck` | `staticcheck` | +| `vet` | `govet` | +| `vetshadow` | `govet` | + +
+v1 + +```yaml +linters: + enable: + - gas + - goerr113 + - gomnd + - logrlint + - megacheck + - vet + - vetshadow +``` + +
+ +
+v2 + +```yaml +linters: + enable: + - gosec + - err113 + - mnd + - loggercheck + - staticcheck + - govet +``` + +
+ +### `stylecheck`, `gosimple`, `staticcheck` + +The three linters `stylecheck`, `gosimple`, and `staticcheck` has been merged inside `staticcheck`. + +
+v1 + +```yaml +linters: + enable: + - gosimple + - staticcheck + - stylecheck +``` + +
+ +
+v2 + +```yaml +linters: + enable: + - staticcheck +``` + +
From 4f8827d7c0ce60804a47f982448828d5ddee4004 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Thu, 13 Mar 2025 00:36:28 +0200 Subject: [PATCH 09/15] Remove migration-guide-base.mdx --- .../src/docs/product/migration-guide-base.mdx | 1677 ----------------- 1 file changed, 1677 deletions(-) delete mode 100644 docs/src/docs/product/migration-guide-base.mdx diff --git a/docs/src/docs/product/migration-guide-base.mdx b/docs/src/docs/product/migration-guide-base.mdx deleted file mode 100644 index 9313c02f0dcb..000000000000 --- a/docs/src/docs/product/migration-guide-base.mdx +++ /dev/null @@ -1,1677 +0,0 @@ ---- -title: Migration guide ---- - -## Command `migrate` - -You can use `golangci-lint` to migrate your configuration through the `migrate` command: - -```sh -golangci-lint migrate -``` - -**Configuration comments are not migrated.** - -**Deprecated options from the v1 or unknown fields are not migrated.** - -The migration file format is based on the extension of the configuration file. -The format can be overridden by using `--format` flag. (ex: `golangci-lint migrate --format yml`) - -Before the migration, the previous configuration file is copied and saved to a file named `.bck.`. - -By default, before the migration process, the configuration file is validated against the JSON Schema of the configuration v1. -If you want to skip this validation, you can use `--skip-validation`. (ex: `golangci-lint migrate --skip-validation`) - -The `migrate` command also enforced some new default values: -- `run.timeout`: the existing value is ignored, because, in v2, by default, there is no timeout. -- `issues.show-stats`: the existing value is ignored, in v2, by default, the stats are enabled. -- `run.concurrency`: if the existing value was `0`, as it's the new default, the key is removed. -- `run.relative-path-mode`: if the existing value was `cfg`, as it's the new default, the key is removed. - -`issues.exclude-generated` has a new default value (v1 `lax`, v2 `strict`), then this field will be added during the migration to keep the previous behavior. - -`issues.exclude-dirs-use-default` has been removed, so this is converted to `linters.exclusions.paths` and, if needed, `formatters.exclusions.paths`. - -Other fields, which are explicitly defined in the configuration file, are migrated even if the value is the same as the default value. - -```txt -Migrate configuration file from v1 to v2 - -Usage: - golangci-lint migrate [flags] - -Flags: - -c, --config PATH Read config from file path PATH - --no-config Don't read config file - --format string Output file format. - By default, the format of the input configuration file is used. - It can be 'yml', 'yaml', 'toml', or 'json'. - --skip-validation Skip validation of the configuration file against the JSON Schema for v1. - -Global Flags: - -h, --help Help for a command - -``` - -## Changes - -### `issues` - -#### `issues.exclude-case-sensitive` - -`issues.exclude`, `issues.exclude-rules.text`, and `issues.exclude-rules.source` are case-sensitive by default. - -To ignore case, use `(?i)` at the beginning of a regex syntax. - -
- v1 - -```yaml -issues: - exclude-case-sensitive: false - exclude: - - 'abcdef' -``` - -
- -
- v2 - -```yaml -linters: - exclusions: - rules: - - path: '(.+)\.go$' - text: (?i)abcdef -``` - -
- -#### `issues.exclude-dirs-use-default` - -
v1 - -```yaml -issues: - exclude-dirs-use-default: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - paths: - - third_party$ - - builtin$ - - examples$ -``` - -
- - -#### `issues.exclude-dirs` - -
v1 - -```yaml -issues: - exclude-dirs: - - src/external_libs - - autogenerated_by_my_lib -``` - -
- -
v2 - -```yaml -linters: - exclusions: - paths: - - src/external_libs - - autogenerated_by_my_lib -``` - -
- -#### `issues.exclude-files` - -
v1 - -```yaml -issues: - exclude-files: - - '.*\.my\.go$' - - lib/bad.go -``` - -
- -
v2 - -```yaml -linters: - exclusions: - paths: - - '.*\.my\.go$' - - lib/bad.go -``` - -
- -#### `issues.exclude-generated-strict` - -Deprecated since v1.59.0. - -
v1 - -```yaml -linters: - exclude-generated-strict: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - generated: strict -``` - -
- -#### `issues.exclude-generated` - -
v1 - -```yaml -linters: - exclude-generated: strict -``` - -
- -
v2 - -```yaml -linters: - exclusions: - generated: strict -``` - -
- -#### `issues.exclude-rules` - -
v1 - -```yaml -issues: - exclude-rules: - - path: '_test\.go' - linters: - - gocyclo - - errcheck - - dupl - - gosec - - path-except: '_test\.go' - linters: - - staticcheck - - path: internal/hmac/ - text: "weak cryptographic primitive" - linters: - - gosec - - linters: - - staticcheck - text: "SA9003:" - - linters: - - err113 - source: "foo" -``` - -
- -
v2 - -```yaml -linters: - exclusions: - rules: - - path: '_test\.go' - linters: - - dupl - - errcheck - - gocyclo - - gosec - - path-except: '_test\.go' - linters: - - staticcheck - - path: internal/hmac/ - text: weak cryptographic primitive - linters: - - gosec - - text: 'SA9003:' - linters: - - staticcheck - - source: foo - linters: - - err113 - ``` - -
- -#### `issues.exclude-use-default` - -
v1 - -```yaml -issues: - exclude-use-default: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - presets: - - comments - - common-false-positives - - legacy - - std-error-handling -``` - -
- -#### `issues.exclude` - -
v1 - -```yaml -issues: - exclude: - - abcdef -``` - -
- -
v2 - -```yaml -linters: - exclusions: - rules: - - path: '(.+)\.go$' - text: abcdef -``` - -
- -#### `issues.include` - -
v1 - -```yaml -issues: - include: - - EXC0014 - - EXC0015 -``` - -
- -
v2 - -```yaml -linters: - exclusions: - presets: - - common-false-positives - - legacy - - std-error-handling -``` - -
- -### `linters-settings` - -`linters-settings` section split to `linters.settings` and `formatters.settings`. - -Settings for `gci`, `gofmt`, `gofumpt`, `goimports` are moved to the `formatters.settings` section. - -
v1 - -```yaml -linters-settings: - lintera: - opt1: foo - # ... - formattera: - opt1: foo - # ... -``` - -
- -
v2 - -```yaml -linters: - # ... - settings: - lintera: - opt1: foo - # ... - -formatters: - # ... - settings: - formattera: - opt1: foo - # ... -``` - -
- -#### `linters-settings.asasalint.ignore-test` - -
v1 - -```yaml -linters-settings: - asasalint: - ignore-test: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - rules: - - path: '(.+)_test\.go' - linters: - - asasalint -``` - -
- -#### `linters-settings.copyloopvar.ignore-alias` - -Deprecated since v1.58.0. - -
v1 - -```yaml -linters-settings: - copyloopvar: - ignore-alias: false -``` - -
- -
v2 - -```yaml -linters: - settings: - copyloopvar: - check-alias: true -``` - -
- -#### `linters-settings.cyclop.skip-tests` - -
v1 - -```yaml -linters-settings: - cyclop: - skip-test: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - rules: - - path: '(.+)_test\.go' - linters: - - cyclop -``` - -
- -#### `linters-settings.errcheck.exclude` - -Deprecated since v1.42.0. - -
v1 - -```yaml -linters-settings: - errcheck: - exclude: /foobar.txt -``` - -
- -
v2 - -```yaml -linters: - settings: - errcheck: - exclude-functions: - - 'example.ReadFile' - - 'example.Copy(*bytes.Buffer)' - - 'example.Copy(os.Stdout)' -``` - -
- -#### `linters-settings.errcheck.ignore` - -Deprecated since v1.13.0. - -
v1 - -```yaml -linters-settings: - errcheck: - ignore: 'example:.*' - -``` - -
- -
v2 - -```yaml -linters: - settings: - errcheck: - exclude-functions: - - 'example.ReadFile' - - 'example.Copy(*bytes.Buffer)' - - 'example.Copy(os.Stdout)' -``` - -
- -#### `linters-settings.exhaustive.check-generated` - -
v1 - -```yaml -linters-settings: - exhaustive: - check-generated: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - generated: strict -``` - -
- -#### `linters-settings.forbidigo.forbid[].p` - -
v1 - -```yaml -linters-settings: - forbidigo: - forbid: - - p: '^fmt\.Print.*$' - msg: Do not commit print statements. -``` - -
- -
v2 - -```yaml -linters: - settings: - forbidigo: - forbid: - - pattern: '^fmt\.Print.*$' - msg: Do not commit print statements. -``` - -
- -#### `linters-settings.forbidigo.forbid[].xxx` - -
v1 - -```yaml -linters-settings: - forbidigo: - forbid: - - '^print(ln)?$' - - '^spew\.(ConfigState\.)?Dump$' -``` - -
- -
v2 - -```yaml -linters: - settings: - forbidigo: - forbid: - - pattern: '^print(ln)?$' - - pattern: '^spew\.(ConfigState\.)?Dump$' -``` - -
- - -#### `linters-settings.gci.local-prefixes` - -Deprecated since v1.44.0. - -
v1 - -```yaml -linters-settings: - gci: - local-prefixes: 'github.com/example/foo' -``` - -
- -
v2 - -```yaml -linters: - settings: - gci: - sections: - - standard - - default - - prefix(github.com/example/foo) -``` - -
- -#### `linters-settings.gci.skip-generated` - -
v1 - -```yaml -linters: - settings: - gci: - skip-generated: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - generated: strict -``` - -
- -#### `linters-settings.goconst.ignore-tests` - -
v1 - -```yaml -linters-settings: - goconst: - ignore-tests: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - rules: - - path: '(.+)_test\.go' - linters: - - goconst -``` - -
- -#### `linters-settings.godot.check-all` - -Deprecated since v1.33.0. - -
v1 - -```yaml -linters-settings: - godot: - check-all: true -``` - -
- -
v2 - -```yaml -linters: - settings: - godot: - scope: all -``` - -
- -#### `linters-settings.gofumpt.lang-version` - -Deprecated since v1.v1.0. - -
v1 - -```yaml -linters-settings: - gofumpt: - lang-version: '1.22' -``` - -
- -
v2 - -```yaml -run: - go: '1.22' -``` - -
- -#### `linters-settings.goimports.local-prefixes` - -
v1 - -```yaml -linters-settings: - goimports: - local-prefixes: 'github.com/example/foo,github.com/example/bar' -``` - -
- -
v2 - -```yaml -linters: - settings: - goimports: - local-prefixes: - - github.com/example/foo - - github.com/example/bar -``` - -
- -#### `linters-settings.gomodguard.local_replace_directives` - -
v1 - -```yaml -linters-settings: - gomodguard: - local_replace_directives: true -``` - -
- -
v2 - -```yaml -linters: - settings: - gomodguard: - local-replace-directives: true -``` - -
- -#### `linters-settings.gosec.exclude-generated` - -
v1 - -```yaml -linters-settings: - gosec: - exclude-generated: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - generated: strict -``` - -
- -#### `linters-settings.gosimple.go` - -Deprecated since v1.47.0. - -
v1 - -```yaml -linters-settings: - gosimple: - go: '1.22' -``` - -
- -
v2 - -```yaml -run: - go: '1.22' -``` - -
- -#### `linters-settings.gosmopolitan.ignore-tests` - -
v1 - -```yaml -linters-settings: - gosmopolitan: - ignore-tests: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - rules: - - path: '(.+)_test\.go' - linters: - - gosmopolitan -``` - -
- -#### `linters-settings.govet.check-shadowing` - -Deprecated since v1.57.0. - -
v1 - -```yaml -linters-settings: - govet: - check-shadowing: true -``` - -
- -
v2 - -```yaml -linters: - settings: - govet: - enable: shadow -``` - -
- -#### `linters-settings.misspell.ignore-words` - -
v1 - -```yaml -linters-settings: - misspell: - ignore-words: - - foo -``` - -
- -
v2 - -```yaml -linters: - settings: - misspell: - ignore-rules: - - foo -``` - -
- -#### `linters-settings.predeclared.ignore` - -
v1 - -```yaml -linters-settings: - predeclared: - ignore: "new,int" -``` - -
- -
v2 - -```yaml -linters: - settings: - predeclared: - ignore: - - new - - int -``` - -
- -#### `linters-settings.predeclared.q` - -
v1 - -```yaml -linters-settings: - predeclared: - q: true -``` - -
- -
v2 - -```yaml -linters: - settings: - predeclared: - qualified-name: true -``` - -
- -#### `linters-settings.revive.ignore-generated-header` - -
v1 - -```yaml -linters-settings: - revive: - ignore-generated-header: true -``` - -
- -
v2 - -```yaml -linters: - exclusions: - generated: strict -``` - -
- -#### `linters-settings.sloglint.context-only` - -Deprecated since v1.58.0. - -
v1 - -```yaml -linters-settings: - sloglint: - context-only: true -``` - -
- -
v2 - -```yaml -linters: - settings: - sloglint: - context: all -``` - -
- -#### `linters-settings.staticcheck.go` - -Deprecated since v1.47.0. - -
v1 - -```yaml -linters-settings: - staticcheck: - go: '1.22' -``` - -
- -
v2 - -```yaml -run: - go: '1.22' -``` - -
- -#### `linters-settings.stylecheck.go` - - -
v1 - -```yaml -linters-settings: - stylecheck: - go: '1.22' -``` - -
- -
v2 - -```yaml -run: - go: '1.22' -``` - -
- - -#### `linters-settings.unused.exported-is-used` - -Deprecated since v1.60.0. - -
v1 - -```yaml -linters-settings: - unused: - exported-is-used: true -``` - -
- -
v2 - -Removed. - -
- -#### `linters-settings.usestdlibvars.os-dev-null` - -Deprecated since v1.51.0. - -
v1 - -```yaml -linters-settings: - usestdlibvars: - os-dev-null: true -``` - -
- -
v2 - -Removed. - -
- -#### `linters-settings.usestdlibvars.syslog-priority` - -Deprecated since v1.51.0. - -
v1 - -```yaml -linters-settings: - usestdlibvars: - syslog-priority: true -``` - -
- -
v2 - -Removed. - -
- -#### `linters-settings.wrapcheck.ignoreInterfaceRegexps` - -
v1 - -```yaml -linters-settings: - wrapcheck: - ignoreInterfaceRegexps: - - '^(?i)c(?-i)ach(ing|e)' -``` - -
- -
v2 - -```yaml -linters: - settings: - wrapcheck: - ignore-interface-regexps: - - '^(?i)c(?-i)ach(ing|e)' -``` - -
- -#### `linters-settings.wrapcheck.ignorePackageGlobs` - -
v1 - -```yaml -linters-settings: - wrapcheck: - ignorePackageGlobs: - - 'encoding/*' -``` - -
- -
v2 - -```yaml -linters: - settings: - wrapcheck: - ignore-package-globs: - - 'encoding/*' -``` - -
- -#### `linters-settings.wrapcheck.ignoreSigRegexps` - -
v1 - -```yaml - linters-settings: - wrapcheck: - ignoreSigRegexps: - - '\.New.*Error\(' -``` - -
- -
v2 - -```yaml -linters: - settings: - wrapcheck: - ignore-sig-regexps: - - '\.New.*Error\(' -``` - -
- -#### `linters-settings.wrapcheck.ignoreSigs` - -
v1 - -```yaml -linters-settings: - wrapcheck: - ignoreSigs: - - '.Errorf(' -``` - -
- -
v2 - -```yaml -linters: - settings: - wrapcheck: - ignore-sigs: - - '.Errorf(' -``` - -
- -### `output` - -#### `output.format` - -
v1 - -```yaml -output: - format: 'checkstyle:report.xml,json:stdout,colored-line-number' -``` - -
- -
v2 - -```yaml -output: - formats: - text: - path: stdout - color: true - json: - path: stdout - checkstyle: - path: 'report.xml' -``` - -
- -#### `output.formats[].format: xxx` - -
v1 - -```yaml -output: - formats: - - format: json - path: stderr - - format: checkstyle - path: 'report.xml' - - format: colored-line-number -``` - -
- -
v2 - -```yaml -output: - formats: - text: - path: stdout - color: true - json: - path: stdout - checkstyle: - path: 'report.xml' -``` - -
- -#### `output.show-stats` - -`output.show-stats` is `true` by default. - -#### `output.sort-order` - -`output.sort-order` has new default: `linter`, `file` instead of `file`. - -#### `output.sort-results` - -`output.sort-results` has been removed: the results are always sorted. - -#### `output.uniq-by-line` - -Deprecated since v1.63.0. - -
v1 - -```yaml -output: - uniq-by-line: true -``` - -
- -
v2 - -```yaml -issues: - uniq-by-line: true -``` - -
- -### `run` - -#### `run.concurrency` - -`run.concurrency` set to match Linux container CPU quota by default and fallback on the number of logical CPUs in the machine. - -#### `run.show-stats` - -Deprecated since v1.57.0. - -
v1 - -```yaml -run: - show-stats: true -``` - -
- -
v2 - -```yaml -output: - show-stats: true -``` - -
- -#### `run.skip-dirs-use-default` - -Deprecated since v1.57.0. - -
v1 - -```yaml -run: - skip-dirs-use-default: false -``` - -
- -
v2 - -```yaml -issues: - exclude-dirs-use-default: false -``` - -
- -#### `run.skip-dirs` - -Deprecated since v1.57.0. - -
v1 - -```yaml -run: - skip-dirs: - - src/external_libs - - autogenerated_by_my_lib -``` - -
- -
v2 - -```yaml -linters: - exclusions: - paths: - - src/external_libs - - autogenerated_by_my_lib -``` - -
- -#### `run.skip-files` - -Deprecated since v1.57.0. - -
v1 - -```yaml -run: - skip-files: - - '.*\.my\.go$' - - lib/bad.go -``` - -
- -
v2 - -```yaml -linters: - exclusions: - paths: - - '.*\.my\.go$' - - lib/bad.go -``` - -
- -#### `run.timeout` - -`run.timeout` is disabled (`0`) by default. - -### `severity` - -#### `severity.default-severity` - -
v1 - -```yaml -severity: - default-severity: error -``` - -
- -
v2 - -```yaml -severity: - default: error -``` - -
- -#### `severity.rules.case-sensitive` - -`severity.rules.text`, and `severity.rules.source` are case-sensitive by default. - -To ignore case, use `(?i)` at the beginning of a regex syntax. - -
v1 - -```yaml -severity: - case-sensitive: true - rules: - - severity: info - linters: - - foo - text: 'Example.*' -``` - -
- -
v2 - -```yaml -severity: - rules: - - severity: info - linters: - - foo - text: '(?i)Example.*' -``` - -
- -### `linters` - -#### `linters.disable-all` - -
v1 - -```yaml -linters: - disable-all: true -``` - -
- -
v2 - -```yaml -linters: - default: none -``` - -
- -#### `linters.enable-all` - -
v1 - -```yaml -linters: - enable-all: true -``` - -
- -
v2 - -```yaml -linters: - default: all -``` - -
- -#### `linters.fast` - -There is no strictly equivalent option in v2 but 2 new options: - -To set all "fast" linters as default linters: - -```yaml -linters: - default: fast -``` - -The new flag option `--fast-only` filters enabled linters to keep only "fast" linters. - -#### `linters.presets` - -The presets have been removed. - -
v1 Presets - -- bugs: - - `asasalint` - - `asciicheck` - - `bidichk` - - `bodyclose` - - `contextcheck` - - `durationcheck` - - `errcheck` - - `errchkjson` - - `errorlint` - - `exhaustive` - - `gocheckcompilerdirectives` - - `gochecksumtype` - - `gosec` - - `gosmopolitan` - - `govet` - - `loggercheck` - - `makezero` - - `musttag` - - `nilerr` - - `nilnesserr` - - `noctx` - - `protogetter` - - `reassign` - - `recvcheck` - - `rowserrcheck` - - `spancheck` - - `sqlclosecheck` - - `staticcheck` - - `testifylint` - - `zerologlint` -- comment: - - `dupword` - - `godot` - - `godox` - - `misspell` -- complexity: - - `cyclop` - - `funlen` - - `gocognit` - - `gocyclo` - - `maintidx` - - `nestif` -- error: - - `err113` - - `errcheck` - - `errorlint` - - `wrapcheck` -- format: - - `gci` - - `gofmt` - - `gofumpt` - - `goimports` -- import: - - `depguard` - - `gci` - - `goimports` - - `gomodguard` -- metalinter: - - `gocritic` - - `govet` - - `revive` - - `staticcheck` -- module: - - `depguard` - - `gomoddirectives` - - `gomodguard` -- performance: - - `bodyclose` - - `fatcontext` - - `noctx` - - `perfsprint` - - `prealloc` -- sql: - - `rowserrcheck` - - `sqlclosecheck` -- style: - - `asciicheck` - - `canonicalheader` - - `containedctx` - - `copyloopvar` - - `decorder` - - `depguard` - - `dogsled` - - `dupl` - - `err113` - - `errname` - - `exhaustruct` - - `exptostd` - - `forbidigo` - - `forcetypeassert` - - `ginkgolinter` - - `gochecknoglobals` - - `gochecknoinits` - - `goconst` - - `gocritic` - - `godot` - - `godox` - - `goheader` - - `gomoddirectives` - - `gomodguard` - - `goprintffuncname` - - `gosimple` - - `grouper` - - `iface` - - `importas` - - `inamedparam` - - `interfacebloat` - - `intrange` - - `ireturn` - - `lll` - - `loggercheck` - - `makezero` - - `mirror` - - `misspell` - - `mnd` - - `musttag` - - `nakedret` - - `nilnil` - - `nlreturn` - - `nolintlint` - - `nonamedreturns` - - `nosprintfhostport` - - `paralleltest` - - `predeclared` - - `promlinter` - - `revive` - - `sloglint` - - `stylecheck` - - `tagalign` - - `tagliatelle` - - `testpackage` - - `tparallel` - - `unconvert` - - `usestdlibvars` - - `varnamelen` - - `wastedassign` - - `whitespace` - - `wrapcheck` - - `wsl` -- test: - - `exhaustruct` - - `paralleltest` - - `testableexamples` - - `testifylint` - - `testpackage` - - `thelper` - - `tparallel` - - `usetesting` -- unused: - - `ineffassign` - - `unparam` - - `unused` - -
- -### Alternative Linter Names - -The alternative linters has been removed. - -| Alt Name v1 | v2 Name | -|-------------|---------------| -| `gas` | `gosec` | -| `goerr113` | `err113` | -| `gomnd` | `mnd` | -| `logrlint` | `loggercheck` | -| `megacheck` | `staticcheck` | -| `vet` | `govet` | -| `vetshadow` | `govet` | - -### `stylecheck`, `gosimple`, `staticcheck` - -The 3 linters `stylecheck`, `gosimple`, `staticcheck` has been merged inside `staticcheck`. From 9f78722747726307d6fd1742bca0e2c3d9e97b7f Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Thu, 13 Mar 2025 16:42:51 +0200 Subject: [PATCH 10/15] review --- docs/src/docs/product/migration-guide.mdx | 70 ++++++++++------------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/docs/src/docs/product/migration-guide.mdx b/docs/src/docs/product/migration-guide.mdx index 78b6f8656dfa..f06871bca3e5 100644 --- a/docs/src/docs/product/migration-guide.mdx +++ b/docs/src/docs/product/migration-guide.mdx @@ -400,7 +400,7 @@ Settings for `gci`, `gofmt`, `gofumpt`, `goimports` are moved to the `formatters ```yaml linters-settings: govet: - disable-all: true + enable-all: true gofmt: simplify: false ``` @@ -414,7 +414,7 @@ linters-settings: linters: settings: govet: - disable-all: true + enable-all: true formatters: settings: @@ -637,7 +637,7 @@ linters: -#### `linters-settings.forbidigo.forbid[].rawPattern` +#### `linters-settings.forbidigo.forbid[]` The `pattern` has become mandatory for the `forbid` field. @@ -821,7 +821,7 @@ linters: #### `linters-settings.predeclared.ignore` -This string option has been replaced with the slice option `linters.settings.predeclared.ignore`. +This string option has been replaced with the slice option with the same name.
v1 @@ -1031,7 +1031,7 @@ linters-settings: #### `linters-settings.wrapcheck.ignoreInterfaceRegexps` -This option has been replaced with `linters.settings.wrapcheck.ignore-interface-regexps`. +This option has been renamed to `linters.settings.wrapcheck.ignore-interface-regexps`.
v1 @@ -1060,7 +1060,7 @@ linters: #### `linters-settings.wrapcheck.ignorePackageGlobs` -This option has been replaced with `linters.settings.wrapcheck.ignore-package-globs`. +This option has been renamed to `linters.settings.wrapcheck.ignore-package-globs`.
v1 @@ -1089,7 +1089,7 @@ linters: #### `linters-settings.wrapcheck.ignoreSigRegexps` -This option has been replaced with `linters.settings.wrapcheck.ignore-sig-regexps`. +This option has been renamed to `linters.settings.wrapcheck.ignore-sig-regexps`.
v1 @@ -1118,7 +1118,7 @@ linters: #### `linters-settings.wrapcheck.ignoreSigs` -This option has been replaced with `linters.settings.wrapcheck.ignore-sigs`. +This option has been renamed to `linters.settings.wrapcheck.ignore-sigs`.
v1 @@ -1167,22 +1167,25 @@ output: ```yaml output: formats: + checkstyle: + path: 'report.xml' + json: + path: stdout text: path: stdout color: true - json: - path: stdout - checkstyle: - path: 'report.xml' ```
-#### `output.formats[].format: name` +#### `output.formats[].format: ` + +The property `output.formats[].format` has been replaced with `output.formats[].`. -The property `output.formats[].format` has been replaced with `output.formats[].formatName`. +The formats `colored-line-number`, `colored-tab` have been replaced by an option `colors`: -The formats `colored-line-number`, `colored-tab` has been removed. Use `output.formats[].text.colors: true` and `output.formats[].tab.colors: true` instead. +- `output.formats[].text.colors: true` +- `output.formats[].tab.colors: true`.
v1 @@ -1222,11 +1225,13 @@ This property is `true` by default. #### `output.sort-order` -This property has new default: [`linter`, `file`] instead of [`file`]. +This property has new default: `['linter', 'file']` instead of `['file']`. #### `output.sort-results` -The property has been removed. The output results are always sorted. +The property has been removed. + +The output results are always sorted. #### `output.uniq-by-line` @@ -1485,29 +1490,16 @@ linters: #### `linters.fast` -This property has been replaced with `linters.default: fast`. It is not a strictly equivalent. - -
-v1 - -```yaml -linters: - fast: true -``` - -
- -
-v2 - -```yaml -linters: - default: fast -``` +This property has been removed. -
+There are 2 new options (they are not strictly equivalent to the previous option): -Also, the new flag option `--fast-only` filters enabled linters to keep only "fast" linters. +1. `linters.default: fast`: set all "fast" linters as the default set of linters. + ```yaml + linters: + default: fast + ``` +2. `--fast-only`: filters all enabled linters to keep only "fast" linters. #### `linters.presets` @@ -1687,7 +1679,7 @@ Presets: The alternative linters has been removed. -| Alt Name V1 | V2 Name | +| Alt Name v1 | Name v2 | |-------------|---------------| | `gas` | `gosec` | | `goerr113` | `err113` | From 32dea6f1e1f0c14877bbfe6c1b3c555ea6f3b9e6 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Thu, 13 Mar 2025 17:15:33 +0200 Subject: [PATCH 11/15] extend guide Add info about `version`, ${base-path}, relative-path-mode, deprecated linters. --- docs/src/docs/product/migration-guide.mdx | 168 ++++++++++++++++++---- 1 file changed, 141 insertions(+), 27 deletions(-) diff --git a/docs/src/docs/product/migration-guide.mdx b/docs/src/docs/product/migration-guide.mdx index f06871bca3e5..4110d0baef8f 100644 --- a/docs/src/docs/product/migration-guide.mdx +++ b/docs/src/docs/product/migration-guide.mdx @@ -760,6 +760,37 @@ linters:
+#### `linters-settings.gocritic.settings.ruleguard.rules` + +The special variable `${configDir}` has been replaced with `${base-path}`. + +
+v1 + +```yaml +linters-settings: + gocritic: + settings: + ruleguard: + rules: '${configDir}/ruleguard/rules-*.go' +``` + +
+ +
+v2 + +```yaml +linters: + settings: + gocritic: + settings: + ruleguard: + rules: '${base-path}/ruleguard/rules-*.go' +``` + +
+ #### `linters-settings.govet.check-shadowing` This option has been deprecated since v1.57.0 and has been removed. @@ -1225,7 +1256,7 @@ This property is `true` by default. #### `output.sort-order` -This property has new default: `['linter', 'file']` instead of `['file']`. +This property has a new default value `['linter', 'file']` instead of `['file']`. #### `output.sort-results` @@ -1263,6 +1294,10 @@ issues: This property value set to match Linux container CPU quota by default and fallback on the number of logical CPUs in the machine. +#### `run.relative-path-mode` + +This property has a new default value of `cfg` instead of `wd`. + #### `run.show-stats` This property has been deprecated since v1.57.0 and replaced by `output.show-stats`. @@ -1488,6 +1523,109 @@ linters:
+### `linters.enable[].` + +`gci`, `gofmt`, `gofumpt`, `goimports` have been moved to the `formatters` section. + +
+v1 + +```yaml +linters: + enable: + - gci + - gofmt + - gofumpt + - goimports +``` + +
+ +
+v2 + +```yaml +formatters: + enable: + - gci + - gofmt + - gofumpt + - goimports +``` + +
+ +### `linters.enable[].{stylecheck,gosimple,staticcheck}` + +The linters `stylecheck`, `gosimple`, and `staticcheck` has been merged inside the `staticcheck`. + +
+v1 + +```yaml +linters: + enable: + - gosimple + - staticcheck + - stylecheck +``` + +
+ +
+v2 + +```yaml +linters: + enable: + - staticcheck +``` + +
+ +### `linters.enable[].typecheck` + +This linter is an internal and enabled by default. + +
+v1 + +```yaml +linters: + enable: + - typecheck +``` + +
+ +
+v2 + +```yaml +# typecheck is always enabled +``` + +
+ +### `linters.enable[].` + +The following deprecated linters have been removed: + +- `deadcode` +- `execinquery` +- `exhaustivestruct` +- `exportloopref` +- `golint` +- `gomnd` +- `ifshort` +- `interfacer` +- `maligned` +- `nosnakecase` +- `scopelint` +- `structcheck` +- `tenv` +- `varcheck` + #### `linters.fast` This property has been removed. @@ -1722,30 +1860,6 @@ linters:
-### `stylecheck`, `gosimple`, `staticcheck` - -The three linters `stylecheck`, `gosimple`, and `staticcheck` has been merged inside `staticcheck`. +### `version` -
-v1 - -```yaml -linters: - enable: - - gosimple - - staticcheck - - stylecheck -``` - -
- -
-v2 - -```yaml -linters: - enable: - - staticcheck -``` - -
+The `version` property has been added to the configuration file. From 4da0531c739f080970454f6f6e74c72f3b727fb5 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Mar 2025 16:21:19 +0100 Subject: [PATCH 12/15] review --- docs/src/docs/product/migration-guide.mdx | 68 +++++++++-------------- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/docs/src/docs/product/migration-guide.mdx b/docs/src/docs/product/migration-guide.mdx index 4110d0baef8f..624bf4da1a4e 100644 --- a/docs/src/docs/product/migration-guide.mdx +++ b/docs/src/docs/product/migration-guide.mdx @@ -1583,49 +1583,6 @@ linters:
-### `linters.enable[].typecheck` - -This linter is an internal and enabled by default. - -
-v1 - -```yaml -linters: - enable: - - typecheck -``` - -
- -
-v2 - -```yaml -# typecheck is always enabled -``` - -
- -### `linters.enable[].` - -The following deprecated linters have been removed: - -- `deadcode` -- `execinquery` -- `exhaustivestruct` -- `exportloopref` -- `golint` -- `gomnd` -- `ifshort` -- `interfacer` -- `maligned` -- `nosnakecase` -- `scopelint` -- `structcheck` -- `tenv` -- `varcheck` - #### `linters.fast` This property has been removed. @@ -1813,6 +1770,31 @@ Presets:
+### `typecheck` + +This `typecheck` is not a linter, so it cannot be enabled or disabled: + +- https://golangci-lint.run/welcome/faq/#why-do-you-have-typecheck-errors +- https://golangci-lint.run/welcome/faq/#why-is-it-not-possible-to-skipignore-typecheck-errors + +### Deprecated Linters + +The following deprecated linters have been removed: + +- `deadcode` +- `execinquery` +- `exhaustivestruct` +- `exportloopref` +- `golint` +- `ifshort` +- `interfacer` +- `maligned` +- `nosnakecase` +- `scopelint` +- `structcheck` +- `tenv` +- `varcheck` + ### Alternative Linter Names The alternative linters has been removed. From 24e52b2180b3210951a66f87710e5a97730d562f Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Thu, 13 Mar 2025 17:48:56 +0200 Subject: [PATCH 13/15] Fix some grammar; extend output section --- docs/src/docs/product/migration-guide.mdx | 197 ++++++++++++++++++++-- 1 file changed, 179 insertions(+), 18 deletions(-) diff --git a/docs/src/docs/product/migration-guide.mdx b/docs/src/docs/product/migration-guide.mdx index 624bf4da1a4e..6db5614c777c 100644 --- a/docs/src/docs/product/migration-guide.mdx +++ b/docs/src/docs/product/migration-guide.mdx @@ -390,9 +390,9 @@ linters: ### `linters-settings` -`linters-settings` section has been split to `linters.settings` and `formatters.settings`. +The `linters-settings` section has been split into `linters.settings` and `formatters.settings`. -Settings for `gci`, `gofmt`, `gofumpt`, `goimports` are moved to the `formatters.settings` section. +Settings for `gci`, `gofmt`, `gofumpt`, and `goimports` are moved to the `formatters.settings` section.
v1 @@ -515,7 +515,7 @@ linters: #### `linters-settings.errcheck.exclude` -This option has been deprecated since v1.42.0. +This option has been deprecated since v1.42.0 and has been removed. To exclude functions, use `linters.settings.errcheck.exclude-functions` instead. @@ -547,7 +547,7 @@ linters: #### `linters-settings.errcheck.ignore` -This option has been deprecated since v1.13.0. +This option has been deprecated since v1.13.0 and has been removed. To exclude functions, use `linters.settings.errcheck.exclude-functions` instead. @@ -558,7 +558,6 @@ To exclude functions, use `linters.settings.errcheck.exclude-functions` instead. linters-settings: errcheck: ignore: 'io:.*' - ```
@@ -582,7 +581,7 @@ linters: This option has been removed. -To analyze generated files use `linters.exclusions.generated`. +To analyze generated files, use `linters.exclusions.generated`.
v1 @@ -704,7 +703,7 @@ linters: This option has been removed. -To analyze generated files use `linters.exclusions.generated`. +To analyze generated files, use `linters.exclusions.generated`.
v1 @@ -1213,11 +1212,6 @@ output: The property `output.formats[].format` has been replaced with `output.formats[].`. -The formats `colored-line-number`, `colored-tab` have been replaced by an option `colors`: - -- `output.formats[].text.colors: true` -- `output.formats[].tab.colors: true`. -
v1 @@ -1227,8 +1221,7 @@ output: - format: json path: stderr - format: checkstyle - path: 'report.xml' - - format: colored-line-number + path: report.xml ```
@@ -1242,7 +1235,59 @@ output: json: path: stderr checkstyle: - path: 'report.xml' + path: report.xml +``` + +
+ +#### `output.formats[].format: line-number` + +This format has been replaced by the format `text`. + +
+v1 + +```yaml +output: + formats: + - format: line-number +``` + +
+ +
+v2 + +```yaml +output: + formats: + text: + path: stdout +``` + +
+ +#### `output.formats[].format: colored-line-number` + +This format has been replaced by the format `text` with the option `colors: true`. + +
+v1 + +```yaml +output: + formats: + - format: colored-line-number +``` + +
+ +
+v2 + +```yaml +output: + formats: text: path: stdout colors: true @@ -1250,6 +1295,98 @@ output:
+#### `output.formats[].format: colored-tab` + +This format has been replaced by the format `tab` with the option `colors: true`. + +
+v1 + +```yaml +output: + formats: + - format: colored-tab +``` + +
+ +
+v2 + +```yaml +output: + formats: + tab: + path: stdout + colors: true +``` + +
+ +#### `output.print-issued-lines` + +This property has been removed. + +To print the lines with issues, use the `text` format with the option `print-issued-lines: true`. + +
+v1 + +```yaml +output: + formats: + - format: line-number + path: stdout + print-issued-lines: true +``` + +
+ +
+v2 + +```yaml +output: + formats: + text: + path: stdout + print-issued-lines: true +``` + +
+ +#### `output.print-linter-name` + +This property has been removed. + +To print the linter name, use the `text` format with the option `print-linter-name: true`. + +
+v1 + +```yaml +output: + formats: + - format: line-number + path: stdout + print-linter-name: true +``` + +
+ +
+v2 + +```yaml +output: + formats: + text: + path: stdout + print-linter-name: true +``` + +
+ #### `output.show-stats` This property is `true` by default. @@ -1290,6 +1427,10 @@ issues: ### `run` +#### `run.go` + +The new fallback value for this property is `1.22` instead of `1.17`. + #### `run.concurrency` This property value set to match Linux container CPU quota by default and fallback on the number of logical CPUs in the machine. @@ -1298,9 +1439,29 @@ This property value set to match Linux container CPU quota by default and fallba This property has a new default value of `cfg` instead of `wd`. +
+v1 + +```yaml +run: + # When not specified, relative-path-mode is set to 'wd' by default +``` + +
+ +
+v2 + +```yaml +run: + relative-path-mode: 'cfg' +``` + +
+ #### `run.show-stats` -This property has been deprecated since v1.57.0 and replaced by `output.show-stats`. +This property has been deprecated since v1.57.0 and has been replaced by `output.show-stats`.
v1 @@ -1324,7 +1485,7 @@ output: #### `run.skip-dirs-use-default` -This property has been deprecated since v1.57.0 and replaced by `issues.exclude-dirs-use-default`. +This property has been deprecated since v1.57.0 and has been replaced by `issues.exclude-dirs-use-default`.
v1 @@ -1525,7 +1686,7 @@ linters: ### `linters.enable[].` -`gci`, `gofmt`, `gofumpt`, `goimports` have been moved to the `formatters` section. +The linters `gci`, `gofmt`, `gofumpt`, and `goimports` have been moved to the `formatters` section.
v1 From e9b2b6683f4daa9a216e060939b0f5378cd04012 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Mar 2025 17:06:49 +0100 Subject: [PATCH 14/15] review --- docs/src/docs/product/migration-guide.mdx | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/src/docs/product/migration-guide.mdx b/docs/src/docs/product/migration-guide.mdx index 6db5614c777c..761f40e45359 100644 --- a/docs/src/docs/product/migration-guide.mdx +++ b/docs/src/docs/product/migration-guide.mdx @@ -1269,7 +1269,7 @@ output: #### `output.formats[].format: colored-line-number` -This format has been replaced by the format `text` with the option `colors: true`. +This format has been replaced by the format `text` with the option `colors` (`true` by default).
v1 @@ -1297,7 +1297,7 @@ output: #### `output.formats[].format: colored-tab` -This format has been replaced by the format `tab` with the option `colors: true`. +This format has been replaced by the format `tab` with the option `colors` (`true` by default).
v1 @@ -1327,7 +1327,7 @@ output: This property has been removed. -To print the lines with issues, use the `text` format with the option `print-issued-lines: true`. +To not print the lines with issues, use the `text` format with the option `print-issued-lines: false`.
v1 @@ -1337,7 +1337,7 @@ output: formats: - format: line-number path: stdout - print-issued-lines: true + print-issued-lines: false ```
@@ -1350,7 +1350,7 @@ output: formats: text: path: stdout - print-issued-lines: true + print-issued-lines: false ```
@@ -1359,7 +1359,7 @@ output: This property has been removed. -To print the linter name, use the `text` format with the option `print-linter-name: true`. +To not print the linter name, use the `text` format with the option `print-linter-name: false`.
v1 @@ -1369,7 +1369,7 @@ output: formats: - format: line-number path: stdout - print-linter-name: true + print-linter-name: false ```
@@ -1382,7 +1382,7 @@ output: formats: text: path: stdout - print-linter-name: true + print-linter-name: false ```
@@ -1684,7 +1684,7 @@ linters:
-### `linters.enable[].` +#### `linters.enable[].` The linters `gci`, `gofmt`, `gofumpt`, and `goimports` have been moved to the `formatters` section. @@ -1716,7 +1716,7 @@ formatters:
-### `linters.enable[].{stylecheck,gosimple,staticcheck}` +#### `linters.enable[].{stylecheck,gosimple,staticcheck}` The linters `stylecheck`, `gosimple`, and `staticcheck` has been merged inside the `staticcheck`. @@ -1931,14 +1931,14 @@ Presets:
-### `typecheck` +#### `typecheck` This `typecheck` is not a linter, so it cannot be enabled or disabled: - https://golangci-lint.run/welcome/faq/#why-do-you-have-typecheck-errors - https://golangci-lint.run/welcome/faq/#why-is-it-not-possible-to-skipignore-typecheck-errors -### Deprecated Linters +#### Deprecated Linters The following deprecated linters have been removed: @@ -1956,7 +1956,7 @@ The following deprecated linters have been removed: - `tenv` - `varcheck` -### Alternative Linter Names +#### Alternative Linter Names The alternative linters has been removed. From a85db46b9e4b6d4109cf3a2c13f3c95944160b86 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Mar 2025 17:15:51 +0100 Subject: [PATCH 15/15] review --- docs/src/docs/product/migration-guide.mdx | 1318 ++++++++++----------- 1 file changed, 659 insertions(+), 659 deletions(-) diff --git a/docs/src/docs/product/migration-guide.mdx b/docs/src/docs/product/migration-guide.mdx index 761f40e45359..731e3d027621 100644 --- a/docs/src/docs/product/migration-guide.mdx +++ b/docs/src/docs/product/migration-guide.mdx @@ -64,112 +64,18 @@ Global Flags: ## Changes -### `issues` - -#### `issues.exclude-case-sensitive` - -This property has been removed. - -`issues.exclude`, `issues.exclude-rules.text`, and `issues.exclude-rules.source` are case-sensitive by default. - -To ignore case, use `(?i)` at the beginning of a regex syntax. - -
-v1 - -```yaml -issues: - exclude-case-sensitive: false - exclude: - - 'abcdef' -``` - -
- -
-v2 - -```yaml -linters: - exclusions: - rules: - - path: '(.+)\.go$' - text: (?i)abcdef -``` - -
- -#### `issues.exclude-dirs-use-default` - -This property has been removed. - -Use `linters.exclusions.paths` and `formatters.exclusions.paths` to exclude directories. - -
-v1 - -```yaml -issues: - exclude-dirs-use-default: true -``` - -
- -
- v2 - -```yaml -linters: - exclusions: - paths: - - third_party$ - - builtin$ - - examples$ -``` - -
+### `linters` -#### `issues.exclude-dirs` +#### `linters.disable-all` -This property has been replaced with `linters.exclusions.paths` and `formatters.exclusions.paths`. +This property has been replaced with `linters.default: none`.
v1 -```yaml -issues: - exclude-dirs: - - src/external_libs - - autogenerated_by_my_lib -``` - -
- -
-v2 - ```yaml linters: - exclusions: - paths: - - src/external_libs - - autogenerated_by_my_lib -``` - -
- -#### `issues.exclude-files` - -This property has been replaced with `linters.exclusions.paths` and `formatters.exclusions.paths`. - -
-v1 - -```yaml -issues: - exclude-files: - - '.*\.my\.go$' - - lib/bad.go + disable-all: true ```
@@ -179,24 +85,21 @@ issues: ```yaml linters: - exclusions: - paths: - - '.*\.my\.go$' - - lib/bad.go + default: none ```
-#### `issues.exclude-generated-strict` +#### `linters.enable-all` -This property has been deprecated since v1.59.0 and has been replaced with `linters.exclusions.generated: strict`. +This property has been replaced with `linters.default: all`.
v1 ```yaml linters: - exclude-generated-strict: true + enable-all: true ```
@@ -206,22 +109,25 @@ linters: ```yaml linters: - exclusions: - generated: strict + default: all ``` -#### `issues.exclude-generated` +#### `linters.enable[].` -This property has been replaced with `linters.exclusions.generated`. +The linters `gci`, `gofmt`, `gofumpt`, and `goimports` have been moved to the `formatters` section.
v1 ```yaml linters: - exclude-generated: lax + enable: + - gci + - gofmt + - gofumpt + - goimports ```
@@ -230,87 +136,29 @@ linters: v2 ```yaml -linters: - exclusions: - generated: lax +formatters: + enable: + - gci + - gofmt + - gofumpt + - goimports ``` -#### `issues.exclude-rules` +#### `linters.enable[].{stylecheck,gosimple,staticcheck}` -This property has been replaced with `linters.exclusions.rules`. +The linters `stylecheck`, `gosimple`, and `staticcheck` has been merged inside the `staticcheck`.
v1 -```yaml -issues: - exclude-rules: - - path: '_test\.go' - linters: - - gocyclo - - errcheck - - dupl - - gosec - - path-except: '_test\.go' - linters: - - staticcheck - - path: internal/hmac/ - text: "weak cryptographic primitive" - linters: - - gosec - - linters: - - staticcheck - text: "SA9003:" - - linters: - - err113 - source: "foo" -``` - -
- -
-v2 - ```yaml linters: - exclusions: - rules: - - path: '_test\.go' - linters: - - dupl - - errcheck - - gocyclo - - gosec - - path-except: '_test\.go' - linters: - - staticcheck - - path: internal/hmac/ - text: weak cryptographic primitive - linters: - - gosec - - text: 'SA9003:' - linters: - - staticcheck - - source: foo - linters: - - err113 - ``` - -
- - -#### `issues.exclude-use-default` - -This property has been replaced with `linters.exclusions.presets`. - -
-v1 - -```yaml -issues: - exclude-use-default: true + enable: + - gosimple + - staticcheck + - stylecheck ```
@@ -320,56 +168,251 @@ issues: ```yaml linters: - exclusions: - presets: - - comments - - common-false-positives - - legacy - - std-error-handling + enable: + - staticcheck ``` -#### `issues.exclude` - -This property has been replaced with `linters.exclusions.rules`. - -
-v1 - -```yaml -issues: - exclude: - - abcdef -``` - -
+#### `linters.fast` -
-v2 +This property has been removed. -```yaml -linters: - exclusions: - rules: - - path: '(.+)\.go$' - text: abcdef -``` +There are 2 new options (they are not strictly equivalent to the previous option): -
+1. `linters.default: fast`: set all "fast" linters as the default set of linters. + ```yaml + linters: + default: fast + ``` +2. `--fast-only`: filters all enabled linters to keep only "fast" linters. -#### `issues.include` +#### `linters.presets` -This property has been replaced with `linters.exclusions.presets`. +This property have been removed.
v1 -```yaml -issues: - include: - - EXC0014 - - EXC0015 +Presets: + +- bugs: + - `asasalint` + - `asciicheck` + - `bidichk` + - `bodyclose` + - `contextcheck` + - `durationcheck` + - `errcheck` + - `errchkjson` + - `errorlint` + - `exhaustive` + - `gocheckcompilerdirectives` + - `gochecksumtype` + - `gosec` + - `gosmopolitan` + - `govet` + - `loggercheck` + - `makezero` + - `musttag` + - `nilerr` + - `nilnesserr` + - `noctx` + - `protogetter` + - `reassign` + - `recvcheck` + - `rowserrcheck` + - `spancheck` + - `sqlclosecheck` + - `staticcheck` + - `testifylint` + - `zerologlint` +- comment: + - `dupword` + - `godot` + - `godox` + - `misspell` +- complexity: + - `cyclop` + - `funlen` + - `gocognit` + - `gocyclo` + - `maintidx` + - `nestif` +- error: + - `err113` + - `errcheck` + - `errorlint` + - `wrapcheck` +- format: + - `gci` + - `gofmt` + - `gofumpt` + - `goimports` +- import: + - `depguard` + - `gci` + - `goimports` + - `gomodguard` +- metalinter: + - `gocritic` + - `govet` + - `revive` + - `staticcheck` +- module: + - `depguard` + - `gomoddirectives` + - `gomodguard` +- performance: + - `bodyclose` + - `fatcontext` + - `noctx` + - `perfsprint` + - `prealloc` +- sql: + - `rowserrcheck` + - `sqlclosecheck` +- style: + - `asciicheck` + - `canonicalheader` + - `containedctx` + - `copyloopvar` + - `decorder` + - `depguard` + - `dogsled` + - `dupl` + - `err113` + - `errname` + - `exhaustruct` + - `exptostd` + - `forbidigo` + - `forcetypeassert` + - `ginkgolinter` + - `gochecknoglobals` + - `gochecknoinits` + - `goconst` + - `gocritic` + - `godot` + - `godox` + - `goheader` + - `gomoddirectives` + - `gomodguard` + - `goprintffuncname` + - `gosimple` + - `grouper` + - `iface` + - `importas` + - `inamedparam` + - `interfacebloat` + - `intrange` + - `ireturn` + - `lll` + - `loggercheck` + - `makezero` + - `mirror` + - `misspell` + - `mnd` + - `musttag` + - `nakedret` + - `nilnil` + - `nlreturn` + - `nolintlint` + - `nonamedreturns` + - `nosprintfhostport` + - `paralleltest` + - `predeclared` + - `promlinter` + - `revive` + - `sloglint` + - `stylecheck` + - `tagalign` + - `tagliatelle` + - `testpackage` + - `tparallel` + - `unconvert` + - `usestdlibvars` + - `varnamelen` + - `wastedassign` + - `whitespace` + - `wrapcheck` + - `wsl` +- test: + - `exhaustruct` + - `paralleltest` + - `testableexamples` + - `testifylint` + - `testpackage` + - `thelper` + - `tparallel` + - `usetesting` +- unused: + - `ineffassign` + - `unparam` + - `unused` + +
+ +
+v2 + +```yaml +# Removed +``` + +
+ +#### `typecheck` + +This `typecheck` is not a linter, so it cannot be enabled or disabled: + +- https://golangci-lint.run/welcome/faq/#why-do-you-have-typecheck-errors +- https://golangci-lint.run/welcome/faq/#why-is-it-not-possible-to-skipignore-typecheck-errors + +#### Deprecated Linters + +The following deprecated linters have been removed: + +- `deadcode` +- `execinquery` +- `exhaustivestruct` +- `exportloopref` +- `golint` +- `ifshort` +- `interfacer` +- `maligned` +- `nosnakecase` +- `scopelint` +- `structcheck` +- `tenv` +- `varcheck` + +#### Alternative Linter Names + +The alternative linters has been removed. + +| Alt Name v1 | Name v2 | +|-------------|---------------| +| `gas` | `gosec` | +| `goerr113` | `err113` | +| `gomnd` | `mnd` | +| `logrlint` | `loggercheck` | +| `megacheck` | `staticcheck` | +| `vet` | `govet` | +| `vetshadow` | `govet` | + +
+v1 + +```yaml +linters: + enable: + - gas + - goerr113 + - gomnd + - logrlint + - megacheck + - vet + - vetshadow ```
@@ -379,11 +422,13 @@ issues: ```yaml linters: - exclusions: - presets: - - common-false-positives - - legacy - - std-error-handling + enable: + - gosec + - err113 + - mnd + - loggercheck + - staticcheck + - govet ``` @@ -1175,18 +1220,24 @@ linters: -### `output` +### `issues` -#### `output.format` +#### `issues.exclude-case-sensitive` -This property has been deprecated since v1.57.0 and has been replaced with `output.formats`. +This property has been removed. + +`issues.exclude`, `issues.exclude-rules.text`, and `issues.exclude-rules.source` are case-sensitive by default. + +To ignore case, use `(?i)` at the beginning of a regex syntax.
v1 ```yaml -output: - format: 'checkstyle:report.xml,json:stdout,colored-line-number' +issues: + exclude-case-sensitive: false + exclude: + - 'abcdef' ```
@@ -1195,62 +1246,57 @@ output: v2 ```yaml -output: - formats: - checkstyle: - path: 'report.xml' - json: - path: stdout - text: - path: stdout - color: true +linters: + exclusions: + rules: + - path: '(.+)\.go$' + text: (?i)abcdef ``` -#### `output.formats[].format: ` +#### `issues.exclude-dirs-use-default` -The property `output.formats[].format` has been replaced with `output.formats[].`. +This property has been removed. + +Use `linters.exclusions.paths` and `formatters.exclusions.paths` to exclude directories.
v1 ```yaml -output: - formats: - - format: json - path: stderr - - format: checkstyle - path: report.xml +issues: + exclude-dirs-use-default: true ```
-v2 + v2 ```yaml -output: - formats: - json: - path: stderr - checkstyle: - path: report.xml +linters: + exclusions: + paths: + - third_party$ + - builtin$ + - examples$ ```
-#### `output.formats[].format: line-number` +#### `issues.exclude-dirs` -This format has been replaced by the format `text`. +This property has been replaced with `linters.exclusions.paths` and `formatters.exclusions.paths`.
v1 ```yaml -output: - formats: - - format: line-number +issues: + exclude-dirs: + - src/external_libs + - autogenerated_by_my_lib ```
@@ -1259,25 +1305,27 @@ output: v2 ```yaml -output: - formats: - text: - path: stdout +linters: + exclusions: + paths: + - src/external_libs + - autogenerated_by_my_lib ``` -#### `output.formats[].format: colored-line-number` +#### `issues.exclude-files` -This format has been replaced by the format `text` with the option `colors` (`true` by default). +This property has been replaced with `linters.exclusions.paths` and `formatters.exclusions.paths`.
v1 ```yaml -output: - formats: - - format: colored-line-number +issues: + exclude-files: + - '.*\.my\.go$' + - lib/bad.go ```
@@ -1286,26 +1334,25 @@ output: v2 ```yaml -output: - formats: - text: - path: stdout - colors: true +linters: + exclusions: + paths: + - '.*\.my\.go$' + - lib/bad.go ``` -#### `output.formats[].format: colored-tab` +#### `issues.exclude-generated-strict` -This format has been replaced by the format `tab` with the option `colors` (`true` by default). +This property has been deprecated since v1.59.0 and has been replaced with `linters.exclusions.generated: strict`.
v1 ```yaml -output: - formats: - - format: colored-tab +linters: + exclude-generated-strict: true ```
@@ -1314,30 +1361,23 @@ output: v2 ```yaml -output: - formats: - tab: - path: stdout - colors: true +linters: + exclusions: + generated: strict ``` -#### `output.print-issued-lines` - -This property has been removed. +#### `issues.exclude-generated` -To not print the lines with issues, use the `text` format with the option `print-issued-lines: false`. +This property has been replaced with `linters.exclusions.generated`.
v1 ```yaml -output: - formats: - - format: line-number - path: stdout - print-issued-lines: false +linters: + exclude-generated: lax ```
@@ -1346,30 +1386,42 @@ output: v2 ```yaml -output: - formats: - text: - path: stdout - print-issued-lines: false +linters: + exclusions: + generated: lax ``` -#### `output.print-linter-name` - -This property has been removed. +#### `issues.exclude-rules` -To not print the linter name, use the `text` format with the option `print-linter-name: false`. +This property has been replaced with `linters.exclusions.rules`.
v1 ```yaml -output: - formats: - - format: line-number - path: stdout - print-linter-name: false +issues: + exclude-rules: + - path: '_test\.go' + linters: + - gocyclo + - errcheck + - dupl + - gosec + - path-except: '_test\.go' + linters: + - staticcheck + - path: internal/hmac/ + text: "weak cryptographic primitive" + linters: + - gosec + - linters: + - staticcheck + text: "SA9003:" + - linters: + - err113 + source: "foo" ```
@@ -1378,39 +1430,43 @@ output: v2 ```yaml -output: - formats: - text: - path: stdout - print-linter-name: false -``` +linters: + exclusions: + rules: + - path: '_test\.go' + linters: + - dupl + - errcheck + - gocyclo + - gosec + - path-except: '_test\.go' + linters: + - staticcheck + - path: internal/hmac/ + text: weak cryptographic primitive + linters: + - gosec + - text: 'SA9003:' + linters: + - staticcheck + - source: foo + linters: + - err113 + ``` -#### `output.show-stats` - -This property is `true` by default. - -#### `output.sort-order` - -This property has a new default value `['linter', 'file']` instead of `['file']`. - -#### `output.sort-results` - -The property has been removed. - -The output results are always sorted. -#### `output.uniq-by-line` +#### `issues.exclude-use-default` -This property has been deprecated since v1.63.0 and has been replaced by `issues.uniq-by-line`. +This property has been replaced with `linters.exclusions.presets`.
v1 ```yaml -output: - uniq-by-line: true +issues: + exclude-use-default: true ```
@@ -1419,32 +1475,28 @@ output: v2 ```yaml -issues: - uniq-by-line: true +linters: + exclusions: + presets: + - comments + - common-false-positives + - legacy + - std-error-handling ``` -### `run` - -#### `run.go` - -The new fallback value for this property is `1.22` instead of `1.17`. - -#### `run.concurrency` - -This property value set to match Linux container CPU quota by default and fallback on the number of logical CPUs in the machine. - -#### `run.relative-path-mode` +#### `issues.exclude` -This property has a new default value of `cfg` instead of `wd`. +This property has been replaced with `linters.exclusions.rules`.
v1 ```yaml -run: - # When not specified, relative-path-mode is set to 'wd' by default +issues: + exclude: + - abcdef ```
@@ -1453,22 +1505,27 @@ run: v2 ```yaml -run: - relative-path-mode: 'cfg' +linters: + exclusions: + rules: + - path: '(.+)\.go$' + text: abcdef ``` -#### `run.show-stats` +#### `issues.include` -This property has been deprecated since v1.57.0 and has been replaced by `output.show-stats`. +This property has been replaced with `linters.exclusions.presets`.
v1 ```yaml -run: - show-stats: true +issues: + include: + - EXC0014 + - EXC0015 ```
@@ -1477,22 +1534,28 @@ run: v2 ```yaml -output: - show-stats: true +linters: + exclusions: + presets: + - common-false-positives + - legacy + - std-error-handling ``` -#### `run.skip-dirs-use-default` +### `output` -This property has been deprecated since v1.57.0 and has been replaced by `issues.exclude-dirs-use-default`. +#### `output.format` + +This property has been deprecated since v1.57.0 and has been replaced with `output.formats`.
v1 ```yaml -run: - skip-dirs-use-default: false +output: + format: 'checkstyle:report.xml,json:stdout,colored-line-number' ```
@@ -1501,26 +1564,33 @@ run: v2 ```yaml -issues: - exclude-dirs-use-default: false +output: + formats: + checkstyle: + path: 'report.xml' + json: + path: stdout + text: + path: stdout + color: true ``` -#### `run.skip-dirs` - -This property has been deprecated since v1.57.0 and has been removed. +#### `output.formats[].format: ` -Use `linters.exclusions.paths` and `formatters.exclusions.paths` to exclude directories. +The property `output.formats[].format` has been replaced with `output.formats[].`.
v1 ```yaml -run: - skip-dirs: - - src/external_libs - - autogenerated_by_my_lib +output: + formats: + - format: json + path: stderr + - format: checkstyle + path: report.xml ```
@@ -1529,29 +1599,27 @@ run: v2 ```yaml -linters: - exclusions: - paths: - - src/external_libs - - autogenerated_by_my_lib +output: + formats: + json: + path: stderr + checkstyle: + path: report.xml ``` -#### `run.skip-files` - -This property has been deprecated since v1.57.0 and has been removed. +#### `output.formats[].format: line-number` -Use `linters.exclusions.paths` and `formatters.exclusions.paths` to exclude files. +This format has been replaced by the format `text`.
v1 ```yaml -run: - skip-files: - - '.*\.my\.go$' - - lib/bad.go +output: + formats: + - format: line-number ```
@@ -1560,31 +1628,53 @@ run: v2 ```yaml -linters: - exclusions: - paths: - - '.*\.my\.go$' - - lib/bad.go +output: + formats: + text: + path: stdout ``` -#### `run.timeout` +#### `output.formats[].format: colored-line-number` -This property value is disabled by default (`0`). +This format has been replaced by the format `text` with the option `colors` (`true` by default). -### `severity` +
+v1 -#### `severity.default-severity` +```yaml +output: + formats: + - format: colored-line-number +``` -This property has been replaced with `severity.default`. +
+ +
+v2 + +```yaml +output: + formats: + text: + path: stdout + colors: true +``` + +
+ +#### `output.formats[].format: colored-tab` + +This format has been replaced by the format `tab` with the option `colors` (`true` by default).
v1 ```yaml -severity: - default-severity: error +output: + formats: + - format: colored-tab ```
@@ -1593,29 +1683,30 @@ severity: v2 ```yaml -severity: - default: error +output: + formats: + tab: + path: stdout + colors: true ``` -#### `severity.rules.case-sensitive` +#### `output.print-issued-lines` -`severity.rules.text` and `severity.rules.source` are case-sensitive by default. +This property has been removed. -To ignore case, use `(?i)` at the beginning of a regex syntax. +To not print the lines with issues, use the `text` format with the option `print-issued-lines: false`.
v1 ```yaml -severity: - case-sensitive: true - rules: - - severity: info - linters: - - foo - text: 'Example.*' +output: + formats: + - format: line-number + path: stdout + print-issued-lines: false ```
@@ -1624,28 +1715,30 @@ severity: v2 ```yaml -severity: - rules: - - severity: info - linters: - - foo - text: '(?i)Example.*' +output: + formats: + text: + path: stdout + print-issued-lines: false ``` -### `linters` +#### `output.print-linter-name` -#### `linters.disable-all` +This property has been removed. -This property has been replaced with `linters.default: none`. +To not print the linter name, use the `text` format with the option `print-linter-name: false`.
v1 ```yaml -linters: - disable-all: true +output: + formats: + - format: line-number + path: stdout + print-linter-name: false ```
@@ -1654,22 +1747,39 @@ linters: v2 ```yaml -linters: - default: none +output: + formats: + text: + path: stdout + print-linter-name: false ``` -#### `linters.enable-all` +#### `output.show-stats` -This property has been replaced with `linters.default: all`. +This property is `true` by default. + +#### `output.sort-order` + +This property has a new default value `['linter', 'file']` instead of `['file']`. + +#### `output.sort-results` + +The property has been removed. + +The output results are always sorted. + +#### `output.uniq-by-line` + +This property has been deprecated since v1.63.0 and has been replaced by `issues.uniq-by-line`.
v1 ```yaml -linters: - enable-all: true +output: + uniq-by-line: true ```
@@ -1678,26 +1788,32 @@ linters: v2 ```yaml -linters: - default: all +issues: + uniq-by-line: true ``` -#### `linters.enable[].` +### `run` -The linters `gci`, `gofmt`, `gofumpt`, and `goimports` have been moved to the `formatters` section. +#### `run.go` + +The new fallback value for this property is `1.22` instead of `1.17`. + +#### `run.concurrency` + +This property value set to match Linux container CPU quota by default and fallback on the number of logical CPUs in the machine. + +#### `run.relative-path-mode` + +This property has a new default value of `cfg` instead of `wd`.
v1 ```yaml -linters: - enable: - - gci - - gofmt - - gofumpt - - goimports +run: + # When not specified, relative-path-mode is set to 'wd' by default ```
@@ -1706,29 +1822,22 @@ linters: v2 ```yaml -formatters: - enable: - - gci - - gofmt - - gofumpt - - goimports +run: + relative-path-mode: 'cfg' ``` -#### `linters.enable[].{stylecheck,gosimple,staticcheck}` +#### `run.show-stats` -The linters `stylecheck`, `gosimple`, and `staticcheck` has been merged inside the `staticcheck`. +This property has been deprecated since v1.57.0 and has been replaced by `output.show-stats`.
v1 ```yaml -linters: - enable: - - gosimple - - staticcheck - - stylecheck +run: + show-stats: true ```
@@ -1737,188 +1846,51 @@ linters: v2 ```yaml -linters: - enable: - - staticcheck +output: + show-stats: true ``` -#### `linters.fast` - -This property has been removed. +#### `run.skip-dirs-use-default` -There are 2 new options (they are not strictly equivalent to the previous option): +This property has been deprecated since v1.57.0 and has been replaced by `issues.exclude-dirs-use-default`. -1. `linters.default: fast`: set all "fast" linters as the default set of linters. - ```yaml - linters: - default: fast - ``` -2. `--fast-only`: filters all enabled linters to keep only "fast" linters. +
+v1 -#### `linters.presets` +```yaml +run: + skip-dirs-use-default: false +``` -This property have been removed. +
-v1 +v2 -Presets: +```yaml +issues: + exclude-dirs-use-default: false +``` -- bugs: - - `asasalint` - - `asciicheck` - - `bidichk` - - `bodyclose` - - `contextcheck` - - `durationcheck` - - `errcheck` - - `errchkjson` - - `errorlint` - - `exhaustive` - - `gocheckcompilerdirectives` - - `gochecksumtype` - - `gosec` - - `gosmopolitan` - - `govet` - - `loggercheck` - - `makezero` - - `musttag` - - `nilerr` - - `nilnesserr` - - `noctx` - - `protogetter` - - `reassign` - - `recvcheck` - - `rowserrcheck` - - `spancheck` - - `sqlclosecheck` - - `staticcheck` - - `testifylint` - - `zerologlint` -- comment: - - `dupword` - - `godot` - - `godox` - - `misspell` -- complexity: - - `cyclop` - - `funlen` - - `gocognit` - - `gocyclo` - - `maintidx` - - `nestif` -- error: - - `err113` - - `errcheck` - - `errorlint` - - `wrapcheck` -- format: - - `gci` - - `gofmt` - - `gofumpt` - - `goimports` -- import: - - `depguard` - - `gci` - - `goimports` - - `gomodguard` -- metalinter: - - `gocritic` - - `govet` - - `revive` - - `staticcheck` -- module: - - `depguard` - - `gomoddirectives` - - `gomodguard` -- performance: - - `bodyclose` - - `fatcontext` - - `noctx` - - `perfsprint` - - `prealloc` -- sql: - - `rowserrcheck` - - `sqlclosecheck` -- style: - - `asciicheck` - - `canonicalheader` - - `containedctx` - - `copyloopvar` - - `decorder` - - `depguard` - - `dogsled` - - `dupl` - - `err113` - - `errname` - - `exhaustruct` - - `exptostd` - - `forbidigo` - - `forcetypeassert` - - `ginkgolinter` - - `gochecknoglobals` - - `gochecknoinits` - - `goconst` - - `gocritic` - - `godot` - - `godox` - - `goheader` - - `gomoddirectives` - - `gomodguard` - - `goprintffuncname` - - `gosimple` - - `grouper` - - `iface` - - `importas` - - `inamedparam` - - `interfacebloat` - - `intrange` - - `ireturn` - - `lll` - - `loggercheck` - - `makezero` - - `mirror` - - `misspell` - - `mnd` - - `musttag` - - `nakedret` - - `nilnil` - - `nlreturn` - - `nolintlint` - - `nonamedreturns` - - `nosprintfhostport` - - `paralleltest` - - `predeclared` - - `promlinter` - - `revive` - - `sloglint` - - `stylecheck` - - `tagalign` - - `tagliatelle` - - `testpackage` - - `tparallel` - - `unconvert` - - `usestdlibvars` - - `varnamelen` - - `wastedassign` - - `whitespace` - - `wrapcheck` - - `wsl` -- test: - - `exhaustruct` - - `paralleltest` - - `testableexamples` - - `testifylint` - - `testpackage` - - `thelper` - - `tparallel` - - `usetesting` -- unused: - - `ineffassign` - - `unparam` - - `unused` +
+ +#### `run.skip-dirs` + +This property has been deprecated since v1.57.0 and has been removed. + +Use `linters.exclusions.paths` and `formatters.exclusions.paths` to exclude directories. + +
+v1 + +```yaml +run: + skip-dirs: + - src/external_libs + - autogenerated_by_my_lib +```
@@ -1926,63 +1898,62 @@ Presets: v2 ```yaml -# Removed +linters: + exclusions: + paths: + - src/external_libs + - autogenerated_by_my_lib ``` -#### `typecheck` +#### `run.skip-files` -This `typecheck` is not a linter, so it cannot be enabled or disabled: +This property has been deprecated since v1.57.0 and has been removed. -- https://golangci-lint.run/welcome/faq/#why-do-you-have-typecheck-errors -- https://golangci-lint.run/welcome/faq/#why-is-it-not-possible-to-skipignore-typecheck-errors +Use `linters.exclusions.paths` and `formatters.exclusions.paths` to exclude files. -#### Deprecated Linters +
+v1 -The following deprecated linters have been removed: +```yaml +run: + skip-files: + - '.*\.my\.go$' + - lib/bad.go +``` -- `deadcode` -- `execinquery` -- `exhaustivestruct` -- `exportloopref` -- `golint` -- `ifshort` -- `interfacer` -- `maligned` -- `nosnakecase` -- `scopelint` -- `structcheck` -- `tenv` -- `varcheck` +
-#### Alternative Linter Names +
+v2 -The alternative linters has been removed. +```yaml +linters: + exclusions: + paths: + - '.*\.my\.go$' + - lib/bad.go +``` -| Alt Name v1 | Name v2 | -|-------------|---------------| -| `gas` | `gosec` | -| `goerr113` | `err113` | -| `gomnd` | `mnd` | -| `logrlint` | `loggercheck` | -| `megacheck` | `staticcheck` | -| `vet` | `govet` | -| `vetshadow` | `govet` | +
+ +#### `run.timeout` + +This property value is disabled by default (`0`). + +### `severity` + +#### `severity.default-severity` + +This property has been replaced with `severity.default`.
v1 ```yaml -linters: - enable: - - gas - - goerr113 - - gomnd - - logrlint - - megacheck - - vet - - vetshadow +severity: + default-severity: error ```
@@ -1991,14 +1962,43 @@ linters: v2 ```yaml -linters: - enable: - - gosec - - err113 - - mnd - - loggercheck - - staticcheck - - govet +severity: + default: error +``` + + + +#### `severity.rules.case-sensitive` + +`severity.rules.text` and `severity.rules.source` are case-sensitive by default. + +To ignore case, use `(?i)` at the beginning of a regex syntax. + +
+v1 + +```yaml +severity: + case-sensitive: true + rules: + - severity: info + linters: + - foo + text: 'Example.*' +``` + +
+ +
+v2 + +```yaml +severity: + rules: + - severity: info + linters: + - foo + text: '(?i)Example.*' ```