From d94cbbf504f36fd509aa767f2b487fb32b6d3f9d Mon Sep 17 00:00:00 2001 From: golangci-releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Sun, 19 May 2024 21:35:28 +0300 Subject: [PATCH 01/19] docs: update GitHub Action assets (#4731) Co-authored-by: Fernandez Ludovic --- .goreleaser.yml | 2 +- CHANGELOG.md | 20 ++++++++++++++------ assets/github-action-config.json | 8 ++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 4a34e4e7ca12..00ee70d847c8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -92,7 +92,7 @@ brews: - repository: owner: golangci name: homebrew-tap - folder: Formula + directory: Formula homepage: https://golangci.com description: Fast linters runner for Go. install: | diff --git a/CHANGELOG.md b/CHANGELOG.md index adb485dec99a..687dd80bbbb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ Follow the news and releases on [Mastodon](https://fosstodon.org/@golangcilint) and on [Twitter](https://twitter.com/golangci). -There is the most valuable changes log: +### v1.58.2 + +1. Updated linters + * `canonicalheader`: from 1.0.6 to 1.1.1 + * `gosec`: from 2.19.0 to 2.20.0 + * `musttag`: from 0.12.1 to 0.12.2 + * `nilnil`: from 0.1.8 to 0.1.9 +2. Documentation + * Improve integrations and install pages ### v1.58.1 @@ -63,7 +71,7 @@ There is the most valuable changes log: * Add `pre-commit` hook to run `config verify` * Improve `github-action` output 6. Documentation - * docs: remove deprecated Atom from Editor Integrations + * Remove deprecated Atom from Editor Integrations GitHub Action (v5.1.0) for golangci-lint: - supports for `pull`, `pull_request_target`, and `merge_group` events with the option `only-new-issues`. @@ -121,8 +129,8 @@ GitHub Action (v5.1.0) for golangci-lint: * `wrapcheck`: from 2.8.1 to 2.8.3 * Disable `copyloopvar` and `intrange` on Go < 1.22 3. Enhancements - * 🧩 New custom linters system https://golangci-lint.run/plugins/module-plugins/ - * 🎉 Allow running only a specific linter without modifying the file configuration (`--enable-only`) + * 🧩New custom linters system https://golangci-lint.run/plugins/module-plugins/ + * Allow running only a specific linter without modifying the file configuration (`--enable-only`) * Allow custom sort order for the reports (`output.sort-order`) * Automatically adjust the maximum concurrency to the container CPU quota if `run.concurrency=0` * Add `config verify` command to check the configuration against the JSON Schema @@ -142,8 +150,8 @@ GitHub Action (v5.1.0) for golangci-lint: * Use `GOTOOLCHAIN=auto` inside the Docker images 5. Documentation * ⚠️ Define the linter deprecation cycle https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle - * 🎉 Use information from the previous release to create linter pages - * 🎉 Publish JSON schema on https://golangci-lint.run/jsonschema/golangci.jsonschema.json + * 🎉Use information from the previous release to create linter pages + * Publish JSON schema on https://golangci-lint.run/jsonschema/golangci.jsonschema.json * Reorganize documentation pages * Add an explanation about the configuration file inside golangci-lint repository diff --git a/assets/github-action-config.json b/assets/github-action-config.json index 4d2c41dd2867..48489b367251 100644 --- a/assets/github-action-config.json +++ b/assets/github-action-config.json @@ -1,8 +1,8 @@ { "MinorVersionToConfig": { "latest": { - "TargetVersion": "v1.58.1", - "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.58.1/golangci-lint-1.58.1-linux-amd64.tar.gz" + "TargetVersion": "v1.58.2", + "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.58.2/golangci-lint-1.58.2-linux-amd64.tar.gz" }, "v1.10": { "Error": "golangci-lint version 'v1.10' isn't supported: we support only v1.14.0 and later versions" @@ -202,8 +202,8 @@ "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.57.2/golangci-lint-1.57.2-linux-amd64.tar.gz" }, "v1.58": { - "TargetVersion": "v1.58.1", - "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.58.1/golangci-lint-1.58.1-linux-amd64.tar.gz" + "TargetVersion": "v1.58.2", + "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.58.2/golangci-lint-1.58.2-linux-amd64.tar.gz" }, "v1.6": { "Error": "golangci-lint version 'v1.6' isn't supported: we support only v1.14.0 and later versions" From be1bb6dbf79aef7e479da4ffdfbd0b0f68e2deb6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 20:36:20 +0200 Subject: [PATCH 02/19] build(deps): bump go-simpler.org/sloglint from 0.6.0 to 0.7.0 (#4718) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 17 +++++++++++ go.mod | 2 +- go.sum | 4 +-- jsonschema/golangci.next.jsonschema.json | 7 +++++ pkg/config/linters_settings.go | 25 +++++++++-------- pkg/golinters/sloglint/sloglint.go | 1 + .../testdata/sloglint_forbidden_keys.go | 28 +++++++++++++++++++ .../testdata/sloglint_forbidden_keys.yml | 4 +++ 8 files changed, 74 insertions(+), 14 deletions(-) create mode 100644 pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.go create mode 100644 pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 361b92c2faf9..da278de696cc 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -1997,12 +1997,15 @@ linters-settings: sloglint: # Enforce not mixing key-value pairs and attributes. + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-mixed-arguments # Default: true no-mixed-args: false # Enforce using key-value pairs only (overrides no-mixed-args, incompatible with attr-only). + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#key-value-pairs-only # Default: false kv-only: true # Enforce using attributes only (overrides no-mixed-args, incompatible with kv-only). + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#attributes-only # Default: false attr-only: true # Enforce not using global loggers. @@ -2010,6 +2013,7 @@ linters-settings: # - "": disabled # - "all": report all global loggers # - "default": report only the default slog logger + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-global # Default: "" no-global: "all" # Enforce using methods that accept a context. @@ -2017,19 +2021,32 @@ linters-settings: # - "": disabled # - "all": report all contextless calls # - "scope": report only if a context exists in the scope of the outermost function + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#context-only # Default: "" context: "all" # Enforce using static values for log messages. + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#static-messages # Default: false static-msg: true # Enforce using constants instead of raw keys. + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-raw-keys # Default: false no-raw-keys: true # Enforce a single key naming convention. # Values: snake, kebab, camel, pascal + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#key-naming-convention # Default: "" key-naming-case: snake + # Enforce not using specific keys. + # Default: [] + forbidden-keys: + - time + - level + - msg + - source + - foo # Enforce putting arguments on separate lines. + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#forbidden-keys # Default: false args-on-sep-lines: true diff --git a/go.mod b/go.mod index 3413a9b1eab2..52524fe7755e 100644 --- a/go.mod +++ b/go.mod @@ -122,7 +122,7 @@ require ( github.com/ykadowak/zerologlint v0.1.5 gitlab.com/bosi/decorder v0.4.2 go-simpler.org/musttag v0.12.2 - go-simpler.org/sloglint v0.6.0 + go-simpler.org/sloglint v0.7.0 go.uber.org/automaxprocs v1.5.3 golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc golang.org/x/tools v0.21.0 diff --git a/go.sum b/go.sum index a92c5a824b97..52b613e66e39 100644 --- a/go.sum +++ b/go.sum @@ -594,8 +594,8 @@ go-simpler.org/assert v0.9.0 h1:PfpmcSvL7yAnWyChSjOz6Sp6m9j5lyK8Ok9pEL31YkQ= go-simpler.org/assert v0.9.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28= go-simpler.org/musttag v0.12.2 h1:J7lRc2ysXOq7eM8rwaTYnNrHd5JwjppzB6mScysB2Cs= go-simpler.org/musttag v0.12.2/go.mod h1:uN1DVIasMTQKk6XSik7yrJoEysGtR2GRqvWnI9S7TYM= -go-simpler.org/sloglint v0.6.0 h1:0YcqSVG7LI9EVBfRPhgPec79BH6X6mwjFuUR5Mr7j1M= -go-simpler.org/sloglint v0.6.0/go.mod h1:+kJJtebtPePWyG5boFwY46COydAggADDOHM22zOvzBk= +go-simpler.org/sloglint v0.7.0 h1:rMZRxD9MbaGoRFobIOicMxZzum7AXNFDlez6xxJs5V4= +go-simpler.org/sloglint v0.7.0/go.mod h1:g9SXiSWY0JJh4LS39/Q0GxzP/QX2cVcbTOYhDpXrJEs= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 5b0082759294..77edb3359731 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -2468,6 +2468,13 @@ "type": "boolean", "default": false }, + "forbidden-keys": { + "description": "Enforce not using specific keys.", + "type": "array", + "items": { + "type": "string" + } + }, "args-on-sep-lines": { "description": "Enforce putting arguments on separate lines.", "type": "boolean", diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index e204328421ce..876b40cfbf83 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -146,10 +146,10 @@ var defaultLintersSettings = LintersSettings{ AttrOnly: false, NoGlobal: "", Context: "", - ContextOnly: false, StaticMsg: false, NoRawKeys: false, KeyNamingCase: "", + ForbiddenKeys: nil, ArgsOnSepLines: false, }, TagAlign: TagAlignSettings{ @@ -819,16 +819,19 @@ type RowsErrCheckSettings struct { } type SlogLintSettings struct { - NoMixedArgs bool `mapstructure:"no-mixed-args"` - KVOnly bool `mapstructure:"kv-only"` - AttrOnly bool `mapstructure:"attr-only"` - NoGlobal string `mapstructure:"no-global"` - Context string `mapstructure:"context"` - ContextOnly bool `mapstructure:"context-only"` // Deprecated: use Context instead. - StaticMsg bool `mapstructure:"static-msg"` - NoRawKeys bool `mapstructure:"no-raw-keys"` - KeyNamingCase string `mapstructure:"key-naming-case"` - ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"` + NoMixedArgs bool `mapstructure:"no-mixed-args"` + KVOnly bool `mapstructure:"kv-only"` + AttrOnly bool `mapstructure:"attr-only"` + NoGlobal string `mapstructure:"no-global"` + Context string `mapstructure:"context"` + StaticMsg bool `mapstructure:"static-msg"` + NoRawKeys bool `mapstructure:"no-raw-keys"` + KeyNamingCase string `mapstructure:"key-naming-case"` + ForbiddenKeys []string `mapstructure:"forbidden-keys"` + ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"` + + // Deprecated: use Context instead. + ContextOnly bool `mapstructure:"context-only"` } type SpancheckSettings struct { diff --git a/pkg/golinters/sloglint/sloglint.go b/pkg/golinters/sloglint/sloglint.go index d3f567e9c7f7..486662577935 100644 --- a/pkg/golinters/sloglint/sloglint.go +++ b/pkg/golinters/sloglint/sloglint.go @@ -20,6 +20,7 @@ func New(settings *config.SlogLintSettings) *goanalysis.Linter { StaticMsg: settings.StaticMsg, NoRawKeys: settings.NoRawKeys, KeyNamingCase: settings.KeyNamingCase, + ForbiddenKeys: settings.ForbiddenKeys, ArgsOnSepLines: settings.ArgsOnSepLines, } } diff --git a/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.go b/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.go new file mode 100644 index 000000000000..b7ef720d110c --- /dev/null +++ b/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.go @@ -0,0 +1,28 @@ +//golangcitest:args -Esloglint +//golangcitest:config_path testdata/sloglint_forbidden_keys.yml +package testdata + +import "log/slog" + +const ( + snakeKey = "foo_bar" +) + +func tests() { + slog.Info("msg") + slog.Info("msg", "foo-bar", 1) + slog.Info("msg", "foo_bar", 1) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", snakeKey, 1) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Int("foo_bar", 1)) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Int(snakeKey, 1)) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Attr{}) + slog.Info("msg", slog.Attr{"foo_bar", slog.IntValue(1)}) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Attr{snakeKey, slog.IntValue(1)}) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Attr{Key: "foo_bar"}) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Attr{Key: snakeKey}) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Attr{Key: "foo_bar", Value: slog.IntValue(1)}) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Attr{Key: snakeKey, Value: slog.IntValue(1)}) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: "foo_bar"}) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: snakeKey}) // want `"foo_bar" key is forbidden and should not be used` + slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: `foo_bar`}) // want `"foo_bar" key is forbidden and should not be used` +} diff --git a/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml b/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml new file mode 100644 index 000000000000..2b0d969cd63c --- /dev/null +++ b/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml @@ -0,0 +1,4 @@ +linters-settings: + sloglint: + forbidden-keys: + - foo_bar From 73110df2cef7c8db91e2703d5b05d41512cf2276 Mon Sep 17 00:00:00 2001 From: Anton Telyshev Date: Sun, 19 May 2024 21:37:03 +0300 Subject: [PATCH 03/19] build(deps): bump github.com/Antonboom/testifylint from 1.2.0 to 1.3.0 (#4729) --- .golangci.next.reference.yml | 12 +++- go.mod | 2 +- go.sum | 4 +- jsonschema/golangci.next.jsonschema.json | 74 ++++++++++++++++++------ pkg/config/linters_settings.go | 4 ++ pkg/goanalysis/linter.go | 2 +- pkg/golinters/testifylint/testifylint.go | 1 + 7 files changed, 74 insertions(+), 25 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index da278de696cc..11a76febf47f 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -2176,9 +2176,10 @@ linters-settings: - error-is-as - error-nil - expected-actual - - go-require - float-compare + - go-require - len + - negative-positive - nil-compare - require-error - suite-dont-use-pkg @@ -2192,7 +2193,7 @@ linters-settings: # Enable checkers by name # (in addition to default # blank-import, bool-compare, compares, empty, error-is-as, error-nil, expected-actual, go-require, float-compare, - # len, nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call, useless-assert + # len, negative-positive, nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call, useless-assert # ). enable: - blank-import @@ -2202,9 +2203,10 @@ linters-settings: - error-is-as - error-nil - expected-actual - - go-require - float-compare + - go-require - len + - negative-positive - nil-compare - require-error - suite-dont-use-pkg @@ -2220,6 +2222,10 @@ linters-settings: # Regexp for expected variable name. # Default: (^(exp(ected)?|want(ed)?)([A-Z]\w*)?$)|(^(\w*[a-z])?(Exp(ected)?|Want(ed)?)$) pattern: ^expected + go-require: + # To ignore HTTP handlers (like http.HandlerFunc). + # Default: false + ignore-http-handlers: true require-error: # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. # Default: "" diff --git a/go.mod b/go.mod index 52524fe7755e..91249f5ef713 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/Abirdcfly/dupword v0.0.14 github.com/Antonboom/errname v0.1.13 github.com/Antonboom/nilnil v0.1.9 - github.com/Antonboom/testifylint v1.2.0 + github.com/Antonboom/testifylint v1.3.0 github.com/BurntSushi/toml v1.3.2 github.com/Crocmagnon/fatcontext v0.2.2 github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 diff --git a/go.sum b/go.sum index 52b613e66e39..db81fb81d76c 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,8 @@ github.com/Antonboom/errname v0.1.13 h1:JHICqsewj/fNckzrfVSe+T33svwQxmjC+1ntDsHO github.com/Antonboom/errname v0.1.13/go.mod h1:uWyefRYRN54lBg6HseYCFhs6Qjcy41Y3Jl/dVhA87Ns= github.com/Antonboom/nilnil v0.1.9 h1:eKFMejSxPSA9eLSensFmjW2XTgTwJMjZ8hUHtV4s/SQ= github.com/Antonboom/nilnil v0.1.9/go.mod h1:iGe2rYwCq5/Me1khrysB4nwI7swQvjclR8/YRPl5ihQ= -github.com/Antonboom/testifylint v1.2.0 h1:015bxD8zc5iY8QwTp4+RG9I4kIbqwvGX9TrBbb7jGdM= -github.com/Antonboom/testifylint v1.2.0/go.mod h1:rkmEqjqVnHDRNsinyN6fPSLnoajzFwsCcguJgwADBkw= +github.com/Antonboom/testifylint v1.3.0 h1:UiqrddKs1W3YK8R0TUuWwrVKlVAnS07DTUVWWs9c+y4= +github.com/Antonboom/testifylint v1.3.0/go.mod h1:NV0hTlteCkViPW9mSR4wEMfwp+Hs1T3dY60bkvSfhpM= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 77edb3359731..abaa7edc8155 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -2779,16 +2779,6 @@ "type": "object", "additionalProperties": false, "properties": { - "bool-compare": { - "type": "object", - "additionalProperties": false, - "properties": { - "ignore-custom-types": { - "type": "boolean", - "default": false - } - } - }, "enable-all": { "description": "Enable all checkers.", "type": "boolean", @@ -2811,9 +2801,10 @@ "error-is-as", "error-nil", "expected-actual", - "go-require", "float-compare", + "go-require", "len", + "negative-positive", "nil-compare", "require-error", "suite-dont-use-pkg", @@ -2821,10 +2812,28 @@ "suite-thelper", "useless-assert" ] - } + }, + "default": [ + "blank-import", + "bool-compare", + "compares", + "empty", + "error-is-as", + "error-nil", + "expected-actual", + "float-compare", + "go-require", + "len", + "negative-positive", + "nil-compare", + "require-error", + "suite-dont-use-pkg", + "suite-extra-assert-call", + "useless-assert" + ] }, "disable": { - "description": "Enable specific checkers.", + "description": "Disable specific checkers.", "type": "array", "items": { "enum": [ @@ -2835,25 +2844,52 @@ "error-is-as", "error-nil", "expected-actual", - "go-require", "float-compare", + "go-require", "len", + "negative-positive", "nil-compare", "require-error", "suite-dont-use-pkg", "suite-extra-assert-call", "suite-thelper", "useless-assert" + ], + "default": [ + "suite-thelper" ] } }, + "bool-compare": { + "type": "object", + "additionalProperties": false, + "properties": { + "ignore-custom-types": { + "description": "To ignore user defined types (over builtin bool).", + "type": "boolean", + "default": false + } + } + }, "expected-actual": { "type": "object", "additionalProperties": false, "properties": { "pattern": { "description": "Regexp for expected variable name.", - "type": "string" + "type": "string", + "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)" + } + } + }, + "go-require": { + "type": "object", + "additionalProperties": false, + "properties": { + "ignore-http-handlers": { + "description": "To ignore HTTP handlers (like http.HandlerFunc).", + "type": "boolean", + "default": false } } }, @@ -2862,8 +2898,9 @@ "additionalProperties": false, "properties": { "fn-pattern": { - "description": "Regexp for expected variable name.", - "type": "string" + "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.", + "type": "string", + "default": "" } } }, @@ -2874,7 +2911,8 @@ "mode": { "description": "To require or remove extra Assert() call?", "type": "string", - "enum": ["remove", "require"] + "enum": ["remove", "require"], + "default": "remove" } } } diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 876b40cfbf83..0ebec511750c 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -882,6 +882,10 @@ type TestifylintSettings struct { ExpVarPattern string `mapstructure:"pattern"` } `mapstructure:"expected-actual"` + GoRequire struct { + IgnoreHTTPHandlers bool `mapstructure:"ignore-http-handlers"` + } `mapstructure:"go-require"` + RequireError struct { FnPattern string `mapstructure:"fn-pattern"` } `mapstructure:"require-error"` diff --git a/pkg/goanalysis/linter.go b/pkg/goanalysis/linter.go index 33f2254b02b1..13d3a09a585a 100644 --- a/pkg/goanalysis/linter.go +++ b/pkg/goanalysis/linter.go @@ -116,7 +116,7 @@ func (*Linter) configureAnalyzer(a *analysis.Analyzer, cfg map[string]any) error } if err := f.Value.Set(valueToString(v)); err != nil { - return fmt.Errorf("failed to set analyzer setting %q with value %v: %w", k, v, err) + return fmt.Errorf("failed to set analyzer setting %q with value %q: %w", k, v, err) } } diff --git a/pkg/golinters/testifylint/testifylint.go b/pkg/golinters/testifylint/testifylint.go index 55c96881d83b..a5f95a1e83a4 100644 --- a/pkg/golinters/testifylint/testifylint.go +++ b/pkg/golinters/testifylint/testifylint.go @@ -18,6 +18,7 @@ func New(settings *config.TestifylintSettings) *goanalysis.Linter { "disable-all": settings.DisableAll, "bool-compare.ignore-custom-types": settings.BoolCompare.IgnoreCustomTypes, + "go-require.ignore-http-handlers": settings.GoRequire.IgnoreHTTPHandlers, } if len(settings.EnabledCheckers) > 0 { cfg[a.Name]["enable"] = settings.EnabledCheckers From 4f5251d3c8f0847c846255ca07377ef54972647f Mon Sep 17 00:00:00 2001 From: Sean Lewis Date: Sun, 19 May 2024 12:38:24 -0600 Subject: [PATCH 04/19] Support Sarif output (#4723) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 1 + jsonschema/golangci.next.jsonschema.json | 3 +- pkg/config/output.go | 2 + pkg/printers/printer.go | 2 + pkg/printers/sarif.go | 109 +++++++++++++++++++++++ pkg/printers/sarif_test.go | 67 ++++++++++++++ 6 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 pkg/printers/sarif.go create mode 100644 pkg/printers/sarif_test.go diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 11a76febf47f..9caca3d783ee 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -71,6 +71,7 @@ output: # - `junit-xml` # - `github-actions` # - `teamcity` + # - `sarif` # Output path can be either `stdout`, `stderr` or path to the file to write to. # # For the CLI flag (`--out-format`), multiple formats can be specified by separating them by comma. diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index abaa7edc8155..5bb029478c40 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -432,7 +432,8 @@ "code-climate", "junit-xml", "github-actions", - "teamcity" + "teamcity", + "sarif" ] } }, diff --git a/pkg/config/output.go b/pkg/config/output.go index a005213cfdce..19d306949089 100644 --- a/pkg/config/output.go +++ b/pkg/config/output.go @@ -19,6 +19,7 @@ const ( OutFormatJunitXML = "junit-xml" OutFormatGithubActions = "github-actions" OutFormatTeamCity = "teamcity" + OutFormatSarif = "sarif" ) var AllOutputFormats = []string{ @@ -33,6 +34,7 @@ var AllOutputFormats = []string{ OutFormatJunitXML, OutFormatGithubActions, OutFormatTeamCity, + OutFormatSarif, } type Output struct { diff --git a/pkg/printers/printer.go b/pkg/printers/printer.go index d2944340874a..53db01220e31 100644 --- a/pkg/printers/printer.go +++ b/pkg/printers/printer.go @@ -135,6 +135,8 @@ func (c *Printer) createPrinter(format string, w io.Writer) (issuePrinter, error p = NewGitHubAction(w) case config.OutFormatTeamCity: p = NewTeamCity(w) + case config.OutFormatSarif: + p = NewSarif(w) default: return nil, fmt.Errorf("unknown output format %q", format) } diff --git a/pkg/printers/sarif.go b/pkg/printers/sarif.go new file mode 100644 index 000000000000..378ee008aed8 --- /dev/null +++ b/pkg/printers/sarif.go @@ -0,0 +1,109 @@ +package printers + +import ( + "encoding/json" + "io" + + "github.com/golangci/golangci-lint/pkg/result" +) + +const ( + sarifVersion = "2.1.0" + sarifSchemaURI = "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.6.json" +) + +type SarifOutput struct { + Version string `json:"version"` + Schema string `json:"$schema"` + Runs []sarifRun `json:"runs"` +} + +type sarifRun struct { + Tool sarifTool `json:"tool"` + Results []sarifResult `json:"results"` +} + +type sarifTool struct { + Driver struct { + Name string `json:"name"` + } `json:"driver"` +} + +type sarifResult struct { + RuleID string `json:"ruleId"` + Level string `json:"level"` + Message sarifMessage `json:"message"` + Locations []sarifLocation `json:"locations"` +} + +type sarifMessage struct { + Text string `json:"text"` +} + +type sarifLocation struct { + PhysicalLocation sarifPhysicalLocation `json:"physicalLocation"` +} + +type sarifPhysicalLocation struct { + ArtifactLocation sarifArtifactLocation `json:"artifactLocation"` + Region sarifRegion `json:"region"` +} + +type sarifArtifactLocation struct { + URI string `json:"uri"` + Index int `json:"index"` +} + +type sarifRegion struct { + StartLine int `json:"startLine"` + StartColumn int `json:"startColumn"` +} + +type Sarif struct { + w io.Writer +} + +func NewSarif(w io.Writer) *Sarif { + return &Sarif{w: w} +} + +func (p Sarif) Print(issues []result.Issue) error { + run := sarifRun{} + run.Tool.Driver.Name = "golangci-lint" + + for i := range issues { + issue := issues[i] + + severity := issue.Severity + if severity == "" { + severity = "error" + } + + sr := sarifResult{ + RuleID: issue.FromLinter, + Level: severity, + Message: sarifMessage{Text: issue.Text}, + Locations: []sarifLocation{ + { + PhysicalLocation: sarifPhysicalLocation{ + ArtifactLocation: sarifArtifactLocation{URI: issue.FilePath()}, + Region: sarifRegion{ + StartLine: issue.Line(), + StartColumn: issue.Column(), + }, + }, + }, + }, + } + + run.Results = append(run.Results, sr) + } + + output := SarifOutput{ + Version: sarifVersion, + Schema: sarifSchemaURI, + Runs: []sarifRun{run}, + } + + return json.NewEncoder(p.w).Encode(output) +} diff --git a/pkg/printers/sarif_test.go b/pkg/printers/sarif_test.go new file mode 100644 index 000000000000..7ebda1210f2a --- /dev/null +++ b/pkg/printers/sarif_test.go @@ -0,0 +1,67 @@ +package printers + +import ( + "bytes" + "go/token" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/golangci/golangci-lint/pkg/result" +) + +func TestSarif_Print(t *testing.T) { + issues := []result.Issue{ + { + FromLinter: "linter-a", + Severity: "warning", + Text: "some issue", + Pos: token.Position{ + Filename: "path/to/filea.go", + Offset: 2, + Line: 10, + Column: 4, + }, + }, + { + FromLinter: "linter-b", + Severity: "error", + Text: "another issue", + SourceLines: []string{ + "func foo() {", + "\tfmt.Println(\"bar\")", + "}", + }, + Pos: token.Position{ + Filename: "path/to/fileb.go", + Offset: 5, + Line: 300, + Column: 9, + }, + }, + { + FromLinter: "linter-a", + Severity: "error", + Text: "some issue 2", + Pos: token.Position{ + Filename: "path/to/filec.go", + Offset: 3, + Line: 11, + Column: 5, + }, + }, + } + + buf := new(bytes.Buffer) + + printer := NewSarif(buf) + + err := printer.Print(issues) + require.NoError(t, err) + + expected := `{"version":"2.1.0","$schema":"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.6.json","runs":[{"tool":{"driver":{"name":"golangci-lint"}},"results":[{"ruleId":"linter-a","level":"warning","message":{"text":"some issue"},"locations":[{"physicalLocation":{"artifactLocation":{"uri":"path/to/filea.go","index":0},"region":{"startLine":10,"startColumn":4}}}]},{"ruleId":"linter-b","level":"error","message":{"text":"another issue"},"locations":[{"physicalLocation":{"artifactLocation":{"uri":"path/to/fileb.go","index":0},"region":{"startLine":300,"startColumn":9}}}]},{"ruleId":"linter-a","level":"error","message":{"text":"some issue 2"},"locations":[{"physicalLocation":{"artifactLocation":{"uri":"path/to/filec.go","index":0},"region":{"startLine":11,"startColumn":5}}}]}]}]} +` + + assert.Equal(t, expected, buf.String()) +} From 867adaf9968d6f7d34ee9ad5dbd67228e7c4868a Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Sun, 19 May 2024 20:38:38 +0200 Subject: [PATCH 05/19] feat: deprecate github-actions format (#4726) --- pkg/config/loader.go | 7 +++++++ pkg/config/output.go | 2 +- pkg/printers/githubaction.go | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/config/loader.go b/pkg/config/loader.go index a48381474c87..3dfe1cfd4d5f 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -350,6 +350,13 @@ func (l *Loader) handleDeprecation() error { l.cfg.Output.Formats = f } + for _, format := range l.cfg.Output.Formats { + if format.Format == OutFormatGithubActions { + l.log.Warnf("The output format `%s` is deprecated, please use `%s`", OutFormatGithubActions, OutFormatColoredLineNumber) + break // To avoid repeating the message if there are several usages of github-actions format. + } + } + l.handleLinterOptionDeprecations() return nil diff --git a/pkg/config/output.go b/pkg/config/output.go index 19d306949089..592e293e0b06 100644 --- a/pkg/config/output.go +++ b/pkg/config/output.go @@ -17,7 +17,7 @@ const ( OutFormatCodeClimate = "code-climate" OutFormatHTML = "html" OutFormatJunitXML = "junit-xml" - OutFormatGithubActions = "github-actions" + OutFormatGithubActions = "github-actions" // Deprecated OutFormatTeamCity = "teamcity" OutFormatSarif = "sarif" ) diff --git a/pkg/printers/githubaction.go b/pkg/printers/githubaction.go index 0d71b1c9b338..a37c4aeb67a4 100644 --- a/pkg/printers/githubaction.go +++ b/pkg/printers/githubaction.go @@ -15,6 +15,7 @@ type GitHubAction struct { } // NewGitHubAction output format outputs issues according to GitHub actions. +// Deprecated func NewGitHubAction(w io.Writer) *GitHubAction { return &GitHubAction{w: w} } From bfca456f22e4a49cd0f468ac62ede3a119608786 Mon Sep 17 00:00:00 2001 From: golangci-releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Sun, 19 May 2024 22:39:46 +0300 Subject: [PATCH 06/19] docs: update documentation (#4732) --- README.md | 94 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 1454da02c7a9..22d072d69432 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ The Core Team has the following responsibilities:
Duco van Amstel

Nishanth Shanmugham

Kensei Nakada
-
Melvin
+
Melvin

quasilyte
@@ -129,7 +129,7 @@ The Core Team has the following responsibilities:
-And 484 more our team members +And 488 more our team members @@ -202,7 +202,7 @@ The Core Team has the following responsibilities: - + @@ -215,82 +215,82 @@ The Core Team has the following responsibilities: + - + - + - + - + - + - + - + - + - @@ -441,10 +441,10 @@ The Core Team has the following responsibilities: - + - + @@ -511,110 +511,110 @@ The Core Team has the following responsibilities: + - + - + - + - + - + - + - + - + - + - + - + - @@ -629,7 +629,7 @@ The Core Team has the following responsibilities: - + @@ -667,94 +667,98 @@ The Core Team has the following responsibilities: + - + - + - + - - + + + - - + + - - + + - - + + - - + + - - + + + + + + - - - +

Henrik Johansson

Florent Viel

Tom Arrell

Choko

Choko

John Starich

Olivier Mengué

Shulhan

Chris Bandy

Patrick Kuca

Viacheslav Poturaev

Catena cyber

@Abirdcfly

Hendry Wiranto

Hendry Wiranto

Robert Liebowitz

Mitar

Zik Aeroh

Paweł Żak

sylvia

Roman Chaliy

Zeal Wierslee

Zeal Wierslee

Kyoh

Tim Kral

Hiroyuki Yagihashi

Denis Voytyuk

Jiangnan Jia

Adam Jones

Kunwardeep

Kunwardeep

Pierre R

Stephan Renatus

Martin Desrumaux

tdakkota

Ivan

Carlos Henrique Guardão Gandarez

Diego Pontoriero

Diego Pontoriero

Daniel Helfand

Benjamin Wang

@796RCP92VZ

Craig Silverstein

Faisal Alam

Alex Collins

Ryo Nakao

Ryo Nakao

Ryan Olds

Matthew Hughes

Matheus Macabu

Tommy Mühle

Sebastiaan van Stijn

Sam Zaydel

Hans Wernetti

Hans Wernetti

Carlos Alexandro Becker

Dominik K.

Joshua Timmons

Sindre Røkenes Myren

Bartłomiej Klimczak

Gabriel Augendre

Fata Nugraha

Fata Nugraha

M. Ángel Jimeno

Jan Oopkaup

Chris Drew

Teiva Harsanyi

Brian Flad

Chris Suszynski

Sean McGinnis

Sean McGinnis

@chenfeining

Kailun Qin

Misha Gusarov

Ariel Mashraki

Shulhan

Oscar

Denis Isaev

Yusuke Kadowaki

@CfirTsabari

Jared Allard

Jared Allard

Navneeth Jayendran

Marko

Chris Lewis

Chris Lewis

Muhammad Ikhsan

Jan Carreras

aimuz

Ryo Sato

Eric Zimanyi

Ben Bernays

Boban Acimovic

Sean Trantalis

Viktor Alenkov

Eduardo Alves

Eduardo Alves

Dima

David Hill

Troy Ronda

Andrey Grazhdankov

Ash McKenzie

Florian Gessner

Osamu TONOMORI

Osamu TONOMORI

Bo Liu

Steven Allen

Colin Arnott

Eran Levy

Roman Leventov

Hugo

Mathias Weber

Mathias Weber

Naveen

@maxsond

Maksim Meshkov

@raffepaffe

Abhinav Gupta

Michael

Evgeniy Kulikov

Evgeniy Kulikov

Chris Nesbitt-Smith

Daniel Caballero

Igor Zibarev

Carl Henderson

Shintaro Anazawa

Matt Braymer-Hayes

Arjen van der Ende

Arjen van der Ende

Pete Davison

Nanguan Lin

Tomas Dabašinskas

@xuri

Charl Matthee

Sriram Venkatesh

Peter Schuller

Peter Schuller

David Golub

Alexander Morozov

Pastoh

Liam White

Alex Dupre

Juanito

Jinming Yue

Jinming Yue

@wxdao

Kévin Dunglas

Sijie Yang

Stephen

Thang Minh Vu

Julia Ogris

Greg Curtis

Greg Curtis

@ac-rappi

Dudás Ádám

Abhishek | अभिषेक

Daniele

Takumasa Sakao

Ben Drucker

Matthew Cobbing

Matthew Cobbing

@Darlez

Kirill Danshin

mook

Kyungmin Bae

Dylan Arbour

Cory Miller

Ben Brown

Ben Brown

Dor

sink

João Freitas

nick

David Bendory

@znley

Jonathan Colby

Jonathan Colby

Justin Robertson

Caleb Xu

Tobias

Namco

aimuz

@andreykuchin

Irina

Tung Leo

Kunal Singh

Kunal Singh

Rui Chen

Rez

Alexandre Vilain

Devin Gunay

Hilário Coelho

Thomas Cave

Sean Lewis

Tibo Delor

@chainchad

Francois Parquet

Robert Kopaczewski

Robert Kopaczewski

Marc Tudurí

@pohang

Cyrille Meichel

neglect-yp

Felix

Adrien

Joe Bergevin

Joe Bergevin

Axetroy

Guillaume JG

Evan Cordell

靳灿奇

Nassos Kat

hitzhangjie

Jesse Donat

Jesse Donat

Oleg Shparber

Tomi Juntunen

Miel Donkers

Marccio Silva

Bastian

KADOTA, Kyohei

Conor Evans

Tiago Silva

KADOTA, Kyohei

Conor Evans

Anirudh Sylendranath

@jumpeiMano

Alex Rodin

Oliver Gugger

Bryan Andrews

@TomerJLevy

Thomas Gorham

@TomerJLevy

Thomas Gorham

Wei Jian Gan

Tamás Gulácsi

Jack Wilsdon

Michał Suchwałko

Alexander Apalikov

Domas Tamašauskas

Stéphane Chausson

Domas Tamašauskas

Stéphane Chausson

neo_sli

@srdhoni

@derekhuizhang

takaokanbe

Sean Schneeweiss

pprzekwas

madflow

pprzekwas

madflow

Arman Tarkhanian

John Adler

@licraft2019

@mlueckest

Malte Ehrlen

@golangaccount

Tyler Dorn

@golangaccount

Tyler Dorn

Enmanuel Moreira

Sylvain Rabot

Piotr Persona

Han Gyoung-Su

Harry Tennent

Kamyar Mirzavaziri

@w1ck3dg0ph3r

Kamyar Mirzavaziri

@w1ck3dg0ph3r

Richard Yuh

caption

Yi Song

guangwu

@wyatterp365

Dmitry Titov

Thomas Bonfort

Matthieu MOREL

Jared Szechy

Wilhelm Ågren

Wilhelm Ågren
From 4beae6a91f8a1f2917bb2f93d8d35b446cc82c2b Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 20 May 2024 15:55:11 +0200 Subject: [PATCH 07/19] fix: remove errcheck defaults (#4734) --- pkg/config/linters_settings.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 0ebec511750c..b2f4567d494d 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -25,9 +25,6 @@ var defaultLintersSettings = LintersSettings{ Dupl: DuplSettings{ Threshold: 150, }, - Errcheck: ErrcheckSettings{ - Ignore: "fmt:.*", - }, ErrorLint: ErrorLintSettings{ Errorf: true, ErrorfMulti: true, From 2c0abaf043706d58cd8cdc6585e5dc44536e50f2 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 20 May 2024 23:03:34 +0200 Subject: [PATCH 08/19] chore: add security policy --- SECURITY.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000000..2e177a225d34 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,14 @@ +# Security Policy + +## Supported Versions + +We support only the current latest version of golangci-lint with the 2 latest minor versions of Go. + +## Reporting a Vulnerability + +To report a potential security vulnerability you create a [security advisory](https://github.com/golangci/golangci-lint/security/advisories). + +In order for us to best respond to your report, please include any of the following: + +- Steps to reproduce or proof-of-concept +- Any relevant information, including versions used From e910d060a486938f37b3e41822995d326ef92fe4 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Tue, 21 May 2024 21:17:28 +0300 Subject: [PATCH 09/19] chore: improve grammar in the security policy (#4739) --- SECURITY.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 2e177a225d34..a4159544b13f 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,13 +2,13 @@ ## Supported Versions -We support only the current latest version of golangci-lint with the 2 latest minor versions of Go. +We only support the latest version of golangci-lint with the two most recent minor versions of Go. ## Reporting a Vulnerability -To report a potential security vulnerability you create a [security advisory](https://github.com/golangci/golangci-lint/security/advisories). +To report a potential security vulnerability, please create a [security advisory](https://github.com/golangci/golangci-lint/security/advisories/new). -In order for us to best respond to your report, please include any of the following: +For us to respond to your report most effectively, please include any of the following: -- Steps to reproduce or proof-of-concept -- Any relevant information, including versions used +- Steps to reproduce or a proof-of-concept +- Any relevant information, including the versions used From 0cb14183e743f51107738c0674c3ea0d58be4a85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 20:17:54 +0200 Subject: [PATCH 10/19] build(deps): bump github.com/go-critic/go-critic from 0.11.3 to 0.11.4 (#4738) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 91249f5ef713..47d41e0f0e91 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( github.com/firefart/nonamedreturns v1.0.5 github.com/fzipp/gocyclo v0.6.0 github.com/ghostiam/protogetter v0.3.6 - github.com/go-critic/go-critic v0.11.3 + github.com/go-critic/go-critic v0.11.4 github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 github.com/go-xmlfmt/xmlfmt v1.1.2 github.com/gofrs/flock v0.8.1 diff --git a/go.sum b/go.sum index db81fb81d76c..b90102e05dec 100644 --- a/go.sum +++ b/go.sum @@ -151,8 +151,8 @@ github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/ghostiam/protogetter v0.3.6 h1:R7qEWaSgFCsy20yYHNIJsU9ZOb8TziSRRxuAOTVKeOk= github.com/ghostiam/protogetter v0.3.6/go.mod h1:7lpeDnEJ1ZjL/YtyoN99ljO4z0pd3H0d18/t2dPBxHw= -github.com/go-critic/go-critic v0.11.3 h1:SJbYD/egY1noYjTMNTlhGaYlfQ77rQmrNH7h+gtn0N0= -github.com/go-critic/go-critic v0.11.3/go.mod h1:Je0h5Obm1rR5hAGA9mP2PDiOOk53W+n7pyvXErFKIgI= +github.com/go-critic/go-critic v0.11.4 h1:O7kGOCx0NDIni4czrkRIXTnit0mkyKOCePh3My6OyEU= +github.com/go-critic/go-critic v0.11.4/go.mod h1:2QAdo4iuLik5S9YG0rT4wcZ8QxwHYkrr6/2MWAiv/vc= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= From b9868e164390f17a5f859211b9c13c2411e6ce99 Mon Sep 17 00:00:00 2001 From: vasyl-haievyi Date: Tue, 21 May 2024 21:06:55 +0200 Subject: [PATCH 11/19] chore: add html to the JSONSchema (#4737) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 1 + .golangci.reference.yml | 1 + jsonschema/golangci.jsonschema.json | 1 + jsonschema/golangci.next.jsonschema.json | 1 + 4 files changed, 4 insertions(+) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 9caca3d783ee..4d002e0205d8 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -66,6 +66,7 @@ output: # - `json` # - `colored-tab` # - `tab` + # - `html` # - `checkstyle` # - `code-climate` # - `junit-xml` diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 6938157dacbb..116306b92c60 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -66,6 +66,7 @@ output: # - `json` # - `colored-tab` # - `tab` + # - `html` # - `checkstyle` # - `code-climate` # - `junit-xml` diff --git a/jsonschema/golangci.jsonschema.json b/jsonschema/golangci.jsonschema.json index e7684df3f395..db22554c1a16 100644 --- a/jsonschema/golangci.jsonschema.json +++ b/jsonschema/golangci.jsonschema.json @@ -428,6 +428,7 @@ "json", "colored-tab", "tab", + "html", "checkstyle", "code-climate", "junit-xml", diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 5bb029478c40..a07bfb6a789b 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -428,6 +428,7 @@ "json", "colored-tab", "tab", + "html", "checkstyle", "code-climate", "junit-xml", From 08deff422526a94181e9b86db604014087bf7128 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 22 May 2024 23:09:43 +0200 Subject: [PATCH 12/19] feat: add warning about disabled and deprecated linters (level 2) (#4742) --- docs/src/docs/product/roadmap.mdx | 7 +++++-- pkg/lint/lintersdb/validator.go | 22 ++++++++++++++++++---- test/run_test.go | 2 -- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/docs/src/docs/product/roadmap.mdx b/docs/src/docs/product/roadmap.mdx index dcca3c88fbce..6753f55e0de0 100644 --- a/docs/src/docs/product/roadmap.mdx +++ b/docs/src/docs/product/roadmap.mdx @@ -47,8 +47,11 @@ A linter can be deprecated for various reasons, e.g. the linter stops working wi The deprecation of a linter will follow 3 phases: -1. **Display of a warning message**: The linter can still be used (unless it's completely non-functional), but it's recommended to remove it from your configuration. -2. **Display of an error message**: At this point, you should remove the linter. The original implementation is replaced by a placeholder that does nothing. +1. **Display of a warning message**: The linter can still be used (unless it's completely non-functional), + but it's recommended to remove it from your configuration. +2. **Display of an error message**: At this point, you should remove the linter. + The original implementation is replaced by a placeholder that does nothing. + The linter is NOT enabled when using `enable-all` and should be removed from the `disable` option. 3. **Removal of the linter** from golangci-lint. Each phase corresponds to a minor version: diff --git a/pkg/lint/lintersdb/validator.go b/pkg/lint/lintersdb/validator.go index 079d8198fa3c..264d063aabb4 100644 --- a/pkg/lint/lintersdb/validator.go +++ b/pkg/lint/lintersdb/validator.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/golangci/golangci-lint/pkg/config" + "github.com/golangci/golangci-lint/pkg/lint/linter" "github.com/golangci/golangci-lint/pkg/logutils" ) @@ -38,17 +39,30 @@ func (v Validator) Validate(cfg *config.Config) error { } func (v Validator) validateLintersNames(cfg *config.Linters) error { - allNames := cfg.Enable - allNames = append(allNames, cfg.Disable...) - var unknownNames []string - for _, name := range allNames { + for _, name := range cfg.Enable { if v.m.GetLinterConfigs(name) == nil { unknownNames = append(unknownNames, name) } } + for _, name := range cfg.Disable { + lcs := v.m.GetLinterConfigs(name) + if len(lcs) == 0 { + unknownNames = append(unknownNames, name) + continue + } + + for _, lc := range lcs { + if lc.IsDeprecated() && lc.Deprecation.Level > linter.DeprecationWarning { + v.m.log.Warnf("The linter %q is deprecated (step 2) and deactivated. "+ + "It should be removed from the list of disabled linters. "+ + "https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle", lc.Name()) + } + } + } + if len(unknownNames) > 0 { return fmt.Errorf("unknown linters: '%v', run 'golangci-lint help linters' to see the list of supported linters", strings.Join(unknownNames, ",")) diff --git a/test/run_test.go b/test/run_test.go index 4c6b870ac07b..9040f0ffd322 100644 --- a/test/run_test.go +++ b/test/run_test.go @@ -100,8 +100,6 @@ func TestCgoOk(t *testing.T) { WithNoConfig(). WithArgs("--timeout=3m", "--enable-all", - "-D", - "nosnakecase", ). WithArgs("--go=1.22"). // TODO(ldez) remove this line when we will run go1.23 on the CI. (related to intrange, copyloopvar) WithTargetPath(testdataDir, "cgo"). From b99d5295f83cbd73b585f469f62f35f222723b84 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Thu, 23 May 2024 16:17:37 +0200 Subject: [PATCH 13/19] feat: allow the analysis of generated files (#4740) --- .golangci.next.reference.yml | 18 +++++----- jsonschema/golangci.next.jsonschema.json | 8 ++--- pkg/commands/flagsets.go | 3 ++ pkg/config/issues.go | 12 ++++--- pkg/config/loader.go | 6 ++++ pkg/lint/runner.go | 2 +- .../processors/autogenerated_exclude.go | 18 +++++++--- .../processors/autogenerated_exclude_test.go | 34 +++++++++---------- 8 files changed, 62 insertions(+), 39 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 4d002e0205d8..1875b4b6f428 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -2872,17 +2872,17 @@ issues: - ".*\\.my\\.go$" - lib/bad.go - # To follow strictly the Go generated file convention. + # Mode of the generated files analysis. # - # If set to true, source files that have lines matching only the following regular expression will be excluded: - # `^// Code generated .* DO NOT EDIT\.$` - # This line must appear before the first non-comment, non-blank text in the file. - # https://go.dev/s/generatedcode + # - `strict`: sources are excluded by following strictly the Go generated file convention. + # Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$` + # This line must appear before the first non-comment, non-blank text in the file. + # https://go.dev/s/generatedcode + # - `lax`: sources are excluded if they contain lines `autogenerated file`, `code generated`, `do not edit`, etc. + # - `disable`: disable the generated files exclusion. # - # By default, a lax pattern is applied: - # sources are excluded if they contain lines `autogenerated file`, `code generated`, `do not edit`, etc. - # Default: false - exclude-generated-strict: true + # Default: lax + exclude-generated: strict # The list of ids of default excludes to include or disable. # https://golangci-lint.run/usage/false-positives/#default-exclusions diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index a07bfb6a789b..7b658258ab0f 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -3518,10 +3518,10 @@ "type": "boolean", "default": false }, - "exclude-generated-strict": { - "description": "To follow strict Go generated file convention", - "type": "boolean", - "default": false + "exclude-generated": { + "description": "Mode of the generated files analysis.", + "enum": ["lax", "strict", "disable"], + "default": "lax" }, "exclude-dirs": { "description": "Which directories to exclude: issues from them won't be reported.", diff --git a/pkg/commands/flagsets.go b/pkg/commands/flagsets.go index f70474cad4a6..608f6b9de581 100644 --- a/pkg/commands/flagsets.go +++ b/pkg/commands/flagsets.go @@ -103,6 +103,9 @@ func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) { internal.AddFlagAndBind(v, fs, fs.Bool, "exclude-dirs-use-default", "issues.exclude-dirs-use-default", true, getDefaultDirectoryExcludeHelp()) + internal.AddFlagAndBind(v, fs, fs.String, "exclude-generated", "issues.exclude-generated", processors.AutogeneratedModeLax, + color.GreenString("Mode of the generated files analysis")) + const newDesc = "Show only new issues: if there are unstaged changes or untracked files, only those changes " + "are analyzed, else only changes in HEAD~ are analyzed.\nIt's a super-useful option for integration " + "of golangci-lint into existing large codebase.\nIt's not practical to fix all existing issues at " + diff --git a/pkg/config/issues.go b/pkg/config/issues.go index 6d48694948d3..2ee9364aaa91 100644 --- a/pkg/config/issues.go +++ b/pkg/config/issues.go @@ -108,12 +108,14 @@ type Issues struct { ExcludeCaseSensitive bool `mapstructure:"exclude-case-sensitive"` ExcludePatterns []string `mapstructure:"exclude"` ExcludeRules []ExcludeRule `mapstructure:"exclude-rules"` - ExcludeGeneratedStrict bool `mapstructure:"exclude-generated-strict"` UseDefaultExcludes bool `mapstructure:"exclude-use-default"` - ExcludeFiles []string `mapstructure:"exclude-files"` - ExcludeDirs []string `mapstructure:"exclude-dirs"` - UseDefaultExcludeDirs bool `mapstructure:"exclude-dirs-use-default"` + ExcludeGenerated string `mapstructure:"exclude-generated"` + + ExcludeFiles []string `mapstructure:"exclude-files"` + ExcludeDirs []string `mapstructure:"exclude-dirs"` + + UseDefaultExcludeDirs bool `mapstructure:"exclude-dirs-use-default"` MaxIssuesPerLinter int `mapstructure:"max-issues-per-linter"` MaxSameIssues int `mapstructure:"max-same-issues"` @@ -124,6 +126,8 @@ type Issues struct { Diff bool `mapstructure:"new"` NeedFix bool `mapstructure:"fix"` + + ExcludeGeneratedStrict bool `mapstructure:"exclude-generated-strict"` // Deprecated: use ExcludeGenerated instead. } func (i *Issues) Validate() error { diff --git a/pkg/config/loader.go b/pkg/config/loader.go index 3dfe1cfd4d5f..70cbcafbfc71 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -357,6 +357,12 @@ func (l *Loader) handleDeprecation() error { } } + // Deprecated since v1.59.0 + if l.cfg.Issues.ExcludeGeneratedStrict { + l.log.Warnf("The configuration option `issues.exclude-generated-strict` is deprecated, please use `issues.exclude-generated`") + l.cfg.Issues.ExcludeGenerated = "strict" // Don't use the constants to avoid cyclic dependencies. + } + l.handleLinterOptionDeprecations() return nil diff --git a/pkg/lint/runner.go b/pkg/lint/runner.go index f4877e1e89c6..f583121ed869 100644 --- a/pkg/lint/runner.go +++ b/pkg/lint/runner.go @@ -75,7 +75,7 @@ func NewRunner(log logutils.Log, cfg *config.Config, args []string, goenv *gouti skipFilesProcessor, skipDirsProcessor, // must be after path prettifier - processors.NewAutogeneratedExclude(cfg.Issues.ExcludeGeneratedStrict), + processors.NewAutogeneratedExclude(cfg.Issues.ExcludeGenerated), // Must be before exclude because users see already marked output and configure excluding by it. processors.NewIdentifierMarker(), diff --git a/pkg/result/processors/autogenerated_exclude.go b/pkg/result/processors/autogenerated_exclude.go index 2fca5117f2b6..5cc5e530ceda 100644 --- a/pkg/result/processors/autogenerated_exclude.go +++ b/pkg/result/processors/autogenerated_exclude.go @@ -12,6 +12,12 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) +const ( + AutogeneratedModeLax = "lax" + AutogeneratedModeStrict = "strict" + AutogeneratedModeDisable = "disable" +) + const ( genCodeGenerated = "code generated" genDoNotEdit = "do not edit" @@ -27,16 +33,16 @@ type fileSummary struct { type AutogeneratedExclude struct { debugf logutils.DebugFunc - strict bool + mode string strictPattern *regexp.Regexp fileSummaryCache map[string]*fileSummary } -func NewAutogeneratedExclude(strict bool) *AutogeneratedExclude { +func NewAutogeneratedExclude(mode string) *AutogeneratedExclude { return &AutogeneratedExclude{ debugf: logutils.Debug(logutils.DebugKeyAutogenExclude), - strict: strict, + mode: mode, strictPattern: regexp.MustCompile(`^// Code generated .* DO NOT EDIT\.$`), fileSummaryCache: map[string]*fileSummary{}, } @@ -47,6 +53,10 @@ func (*AutogeneratedExclude) Name() string { } func (p *AutogeneratedExclude) Process(issues []result.Issue) ([]result.Issue, error) { + if p.mode == AutogeneratedModeDisable { + return issues, nil + } + return filterIssuesErr(issues, p.shouldPassIssue) } @@ -71,7 +81,7 @@ func (p *AutogeneratedExclude) shouldPassIssue(issue *result.Issue) (bool, error fs = &fileSummary{} p.fileSummaryCache[issue.FilePath()] = fs - if p.strict { + if p.mode == AutogeneratedModeStrict { var err error fs.generated, err = p.isGeneratedFileStrict(issue.FilePath()) if err != nil { diff --git a/pkg/result/processors/autogenerated_exclude_test.go b/pkg/result/processors/autogenerated_exclude_test.go index b2a51caf28b1..34c5c512f8db 100644 --- a/pkg/result/processors/autogenerated_exclude_test.go +++ b/pkg/result/processors/autogenerated_exclude_test.go @@ -14,7 +14,7 @@ import ( ) func TestAutogeneratedExclude_isGeneratedFileLax_generated(t *testing.T) { - p := NewAutogeneratedExclude(false) + p := NewAutogeneratedExclude(AutogeneratedModeLax) comments := []string{ ` // generated by stringer -type Pill pill.go; DO NOT EDIT`, @@ -56,7 +56,7 @@ func TestAutogeneratedExclude_isGeneratedFileLax_generated(t *testing.T) { } func TestAutogeneratedExclude_isGeneratedFileLax_nonGenerated(t *testing.T) { - p := NewAutogeneratedExclude(false) + p := NewAutogeneratedExclude(AutogeneratedModeLax) comments := []string{ "code not generated by", @@ -75,7 +75,7 @@ func TestAutogeneratedExclude_isGeneratedFileLax_nonGenerated(t *testing.T) { } func TestAutogeneratedExclude_isGeneratedFileStrict(t *testing.T) { - p := NewAutogeneratedExclude(true) + p := NewAutogeneratedExclude(AutogeneratedModeStrict) testCases := []struct { desc string @@ -154,21 +154,21 @@ func Test_getComments_fileWithLongLine(t *testing.T) { func Test_shouldPassIssue(t *testing.T) { testCases := []struct { desc string - strict bool + mode string issue *result.Issue assert assert.BoolAssertionFunc }{ { - desc: "typecheck issue", - strict: false, + desc: "typecheck issue", + mode: AutogeneratedModeLax, issue: &result.Issue{ FromLinter: "typecheck", }, assert: assert.True, }, { - desc: "lax ", - strict: false, + desc: "lax ", + mode: AutogeneratedModeLax, issue: &result.Issue{ FromLinter: "example", Pos: token.Position{ @@ -178,8 +178,8 @@ func Test_shouldPassIssue(t *testing.T) { assert: assert.False, }, { - desc: "strict ", - strict: true, + desc: "strict ", + mode: AutogeneratedModeStrict, issue: &result.Issue{ FromLinter: "example", Pos: token.Position{ @@ -195,7 +195,7 @@ func Test_shouldPassIssue(t *testing.T) { t.Run(test.desc, func(t *testing.T) { t.Parallel() - p := NewAutogeneratedExclude(test.strict) + p := NewAutogeneratedExclude(test.mode) pass, err := p.shouldPassIssue(test.issue) require.NoError(t, err) @@ -213,13 +213,13 @@ func Test_shouldPassIssue_error(t *testing.T) { testCases := []struct { desc string - strict bool + mode string issue *result.Issue expected string }{ { - desc: "non-existing file (lax)", - strict: false, + desc: "non-existing file (lax)", + mode: AutogeneratedModeLax, issue: &result.Issue{ FromLinter: "example", Pos: token.Position{ @@ -230,8 +230,8 @@ func Test_shouldPassIssue_error(t *testing.T) { filepath.FromSlash("no-existing.go"), notFoundMsg), }, { - desc: "non-existing file (strict)", - strict: true, + desc: "non-existing file (strict)", + mode: AutogeneratedModeStrict, issue: &result.Issue{ FromLinter: "example", Pos: token.Position{ @@ -248,7 +248,7 @@ func Test_shouldPassIssue_error(t *testing.T) { t.Run(test.desc, func(t *testing.T) { t.Parallel() - p := NewAutogeneratedExclude(test.strict) + p := NewAutogeneratedExclude(test.mode) pass, err := p.shouldPassIssue(test.issue) From 010b4f856c2640c51be76b216edd25128c04afec Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 23 May 2024 18:20:50 +0200 Subject: [PATCH 14/19] chore: use global security policy --- SECURITY.md | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index a4159544b13f..000000000000 --- a/SECURITY.md +++ /dev/null @@ -1,14 +0,0 @@ -# Security Policy - -## Supported Versions - -We only support the latest version of golangci-lint with the two most recent minor versions of Go. - -## Reporting a Vulnerability - -To report a potential security vulnerability, please create a [security advisory](https://github.com/golangci/golangci-lint/security/advisories/new). - -For us to respond to your report most effectively, please include any of the following: - -- Steps to reproduce or a proof-of-concept -- Any relevant information, including the versions used From e14ae4b7d11de5fafaf9c150ed67bb179af68c4f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 14:21:25 +0200 Subject: [PATCH 15/19] build(deps): bump github.com/hashicorp/go-version from 1.6.0 to 1.7.0 (#4745) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 47d41e0f0e91..5f2a54522f29 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/gordonklaus/ineffassign v0.1.0 github.com/gostaticanalysis/forcetypeassert v0.1.0 github.com/gostaticanalysis/nilerr v0.1.1 - github.com/hashicorp/go-version v1.6.0 + github.com/hashicorp/go-version v1.7.0 github.com/hexops/gotextdiff v1.0.3 github.com/jgautheron/goconst v1.7.1 github.com/jingyugao/rowserrcheck v1.1.1 diff --git a/go.sum b/go.sum index b90102e05dec..3b5b0bb1b82c 100644 --- a/go.sum +++ b/go.sum @@ -288,8 +288,8 @@ github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod github.com/gostaticanalysis/testutil v0.4.0 h1:nhdCmubdmDF6VEatUNjgUZBJKWRqugoISdUv3PPQgHY= github.com/gostaticanalysis/testutil v0.4.0/go.mod h1:bLIoPefWXrRi/ssLFWX1dx7Repi5x3CuviD3dgAZaBU= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= From 62c83ccd2994e40eb7d59a7f0e25fc93f15d5995 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 14:22:24 +0200 Subject: [PATCH 16/19] build(deps): bump github.com/BurntSushi/toml from 1.3.2 to 1.4.0 (#4746) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5f2a54522f29..df59eb145871 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/Antonboom/errname v0.1.13 github.com/Antonboom/nilnil v0.1.9 github.com/Antonboom/testifylint v1.3.0 - github.com/BurntSushi/toml v1.3.2 + github.com/BurntSushi/toml v1.4.0 github.com/Crocmagnon/fatcontext v0.2.2 github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0 diff --git a/go.sum b/go.sum index 3b5b0bb1b82c..3686bbceb762 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,8 @@ github.com/Antonboom/nilnil v0.1.9/go.mod h1:iGe2rYwCq5/Me1khrysB4nwI7swQvjclR8/ github.com/Antonboom/testifylint v1.3.0 h1:UiqrddKs1W3YK8R0TUuWwrVKlVAnS07DTUVWWs9c+y4= github.com/Antonboom/testifylint v1.3.0/go.mod h1:NV0hTlteCkViPW9mSR4wEMfwp+Hs1T3dY60bkvSfhpM= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Crocmagnon/fatcontext v0.2.2 h1:OrFlsDdOj9hW/oBEJBNSuH7QWf+E9WPVHw+x52bXVbk= github.com/Crocmagnon/fatcontext v0.2.2/go.mod h1:WSn/c/+MMNiD8Pri0ahRj0o9jVpeowzavOQplBJw6u0= From 495321c9b408dbc0dbd4601a1b317209a8211510 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Fri, 24 May 2024 22:49:53 +0200 Subject: [PATCH 17/19] dev: improve issue chooser (#4747) --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 11 +++++++---- .github/ISSUE_TEMPLATE/feature_request.yml | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 714879eddc53..d798d0e38bf9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,4 +1,4 @@ -name: Bug Report +name: 🐞 Bug Report description: "Create a report to help us improve." labels: [bug] body: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index eaab4a3ce01a..558c4b8625db 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,11 @@ blank_issues_enabled: false contact_links: - - name: Questions - url: https://github.com/golangci/golangci-lint/discussions - about: If you have a question, or are looking for advice, please post on our Discussions forum! - - name: golangci-lint documentation + - name: 📖 Documentation url: https://golangci-lint.run about: Please take a look to our documentation. + - name: ❓ Questions + url: https://github.com/golangci/golangci-lint/discussions + about: If you have a question, or are looking for advice, please post on our Discussions forum! + - name: 💬 Chat on Slack + url: https://gophers.slack.com/archives/CS0TBRKPC + about: Maybe chatting with the community can help diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 27541f8df4ef..c2d626f595b6 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,4 +1,4 @@ -name: Feature Request +name: 💡 Feature request description: "Suggest an idea for this project." labels: [enhancement] body: From 95ca3c3c855a36a8aaa877e27421d035d47c42e3 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 25 May 2024 01:16:27 +0200 Subject: [PATCH 18/19] dev: fix badges --- .github/contributors/rewrite_readme.ts | 5 +++-- README.md | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/contributors/rewrite_readme.ts b/.github/contributors/rewrite_readme.ts index eeccce532e2b..3417b2ea90ff 100644 --- a/.github/contributors/rewrite_readme.ts +++ b/.github/contributors/rewrite_readme.ts @@ -65,17 +65,18 @@ const buildContributorsContent = (): string => {
About core team -The GolangCI Core Team is a group of contributors that have demonstrated a lasting enthusiasm for the project and community. +The GolangCI Core Team is a group of contributors who have demonstrated a lasting enthusiasm for the project and community. The GolangCI Core Team has GitHub admin privileges on the repo. #### Responsibilities + The Core Team has the following responsibilities: 1. Being available to answer high-level questions about vision and future. 2. Being available to review longstanding/forgotten pull requests. 3. Occasionally check issues, offer input, and categorize with GitHub issue labels. 4. Looking out for up-and-coming members of the GolangCI community who might want to serve as Core Team members. -5. Note that the Core Team – and all GolangCI contributors – are open source volunteers; membership on the Core Team is expressly not an obligation. The Core Team is distinguished as leaders in the community and while they are a good group to turn to when someone needs an answer to a question, they are still volunteering their time, and may not be available to help immediately. +5. Note that the Core Team – and all GolangCI contributors – are open-source volunteers; membership on the Core Team is expressly not an obligation. The Core Team is distinguished as leaders in the community and while they are a good group to turn to when someone needs an answer to a question, they are still volunteering their time, and may not be available to help immediately.
diff --git a/README.md b/README.md index 22d072d69432..fde307f83a1c 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ Documentation is hosted at https://golangci-lint.run. ## Supporting Us -[![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/golangci-lint?logo=opencollective&style=for-the-badge)](https://opencollective.com/golangci-lint) -[![GitHub Sponsors](https://img.shields.io/github/sponsors/golangci?logo=github&style=for-the-badge)](https://github.com/sponsors/golangci) -[![Linter Authors](https://img.shields.io/badge/Linter-Authors-blue?style=for-the-badge)](https://golangci-lint.run/product/thanks/) + +[![Open Collective backers and sponsors](https://img.shields.io/badge/OpenCollective-Donate-blue?logo=opencollective&style=for-the-badge)](https://opencollective.com/golangci-lint) +[![Linter Authors](https://img.shields.io/badge/Linter_Authors-Donate-blue?style=for-the-badge)](https://golangci-lint.run/product/thanks/) `golangci-lint` is a free and open-source project built by volunteers. @@ -56,17 +56,18 @@ This project exists thanks to all the people who contribute. [How to contribute]
About core team -The GolangCI Core Team is a group of contributors that have demonstrated a lasting enthusiasm for the project and community. +The GolangCI Core Team is a group of contributors who have demonstrated a lasting enthusiasm for the project and community. The GolangCI Core Team has GitHub admin privileges on the repo. #### Responsibilities + The Core Team has the following responsibilities: 1. Being available to answer high-level questions about vision and future. 2. Being available to review longstanding/forgotten pull requests. 3. Occasionally check issues, offer input, and categorize with GitHub issue labels. 4. Looking out for up-and-coming members of the GolangCI community who might want to serve as Core Team members. -5. Note that the Core Team – and all GolangCI contributors – are open source volunteers; membership on the Core Team is expressly not an obligation. The Core Team is distinguished as leaders in the community and while they are a good group to turn to when someone needs an answer to a question, they are still volunteering their time, and may not be available to help immediately. +5. Note that the Core Team – and all GolangCI contributors – are open-source volunteers; membership on the Core Team is expressly not an obligation. The Core Team is distinguished as leaders in the community and while they are a good group to turn to when someone needs an answer to a question, they are still volunteering their time, and may not be available to help immediately.
From 2059b18a39d559552839476ba78ce6acaa499b43 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Sat, 25 May 2024 13:38:08 +0200 Subject: [PATCH 19/19] build(deps): bump github.com/securego/gosec/v2 from 2.20.0 to 5f0084eb01a9 (#4748) --- go.mod | 2 +- go.sum | 8 ++++---- pkg/config/loader.go | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index df59eb145871..c734c14b18cf 100644 --- a/go.mod +++ b/go.mod @@ -92,7 +92,7 @@ require ( github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 github.com/sashamelentyev/interfacebloat v1.1.0 github.com/sashamelentyev/usestdlibvars v1.25.0 - github.com/securego/gosec/v2 v2.20.0 + github.com/securego/gosec/v2 v2.20.1-0.20240525090044-5f0084eb01a9 github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c github.com/shirou/gopsutil/v3 v3.24.4 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 3686bbceb762..5a8c9fd039c1 100644 --- a/go.sum +++ b/go.sum @@ -403,8 +403,8 @@ github.com/nunnatsa/ginkgolinter v0.16.2 h1:8iLqHIZvN4fTLDC0Ke9tbSZVcyVHoBs0HIbn github.com/nunnatsa/ginkgolinter v0.16.2/go.mod h1:4tWRinDN1FeJgU+iJANW/kz7xKN5nYRAOfJDQUS9dOQ= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo/v2 v2.17.2 h1:7eMhcy3GimbsA3hEnVKdw/PQM9XN9krpKVXsZdph0/g= -github.com/onsi/ginkgo/v2 v2.17.2/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= +github.com/onsi/ginkgo/v2 v2.17.3 h1:oJcvKpIb7/8uLpDDtnQuf18xVnwKp8DTD7DQ6gTd/MU= +github.com/onsi/ginkgo/v2 v2.17.3/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= @@ -478,8 +478,8 @@ github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tM github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ= github.com/sashamelentyev/usestdlibvars v1.25.0 h1:IK8SI2QyFzy/2OD2PYnhy84dpfNo9qADrRt6LH8vSzU= github.com/sashamelentyev/usestdlibvars v1.25.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= -github.com/securego/gosec/v2 v2.20.0 h1:z/d5qp1niWa2avgFyUIglYTYYuGq2LrJwNj1HRVXsqc= -github.com/securego/gosec/v2 v2.20.0/go.mod h1:hkiArbBZLwK1cehBcg3oFWUlYPWTBffPwwJVWChu83o= +github.com/securego/gosec/v2 v2.20.1-0.20240525090044-5f0084eb01a9 h1:rnO6Zp1YMQwv8AyxzuwsVohljJgp4L0ZqiCgtACsPsc= +github.com/securego/gosec/v2 v2.20.1-0.20240525090044-5f0084eb01a9/go.mod h1:dg7lPlu/xK/Ut9SedURCoZbVCR4yC7fM65DtH9/CDHs= github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c h1:W65qqJCIOVP4jpqPQ0YvHYKwcMEMVWIzWC5iNQQfBTU= github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs= github.com/shirou/gopsutil/v3 v3.24.4 h1:dEHgzZXt4LMNm+oYELpzl9YCqV65Yr/6SfrvgRBtXeU= diff --git a/pkg/config/loader.go b/pkg/config/loader.go index 70cbcafbfc71..ea4cae2d5542 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -304,6 +304,8 @@ func (l *Loader) handleGoVersion() { if l.cfg.LintersSettings.Stylecheck.GoVersion == "" { l.cfg.LintersSettings.Stylecheck.GoVersion = trimmedGoVersion } + + os.Setenv("GOSECGOVERSION", l.cfg.Run.Go) } func (l *Loader) handleDeprecation() error {