diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index 2580aaf89a85..c5ba44d72632 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -37,7 +37,7 @@ jobs:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
go-version: ${{ env.GO_VERSION }}
- name: lint
- uses: golangci/golangci-lint-action@v3.1.0
+ uses: golangci/golangci-lint-action@v3.2.0
with:
version: latest
# skip cache because of flaky behaviors
diff --git a/.golangci.example.yml b/.golangci.reference.yml
similarity index 99%
rename from .golangci.example.yml
rename to .golangci.reference.yml
index 6bed0b21abc0..131458efa9f9 100644
--- a/.golangci.example.yml
+++ b/.golangci.reference.yml
@@ -1,5 +1,8 @@
# This file contains all available configuration options
# with their default values (in comments).
+#
+# This file is not a configuration example,
+# it contains the exhaustive configuration with explanations of the options.
# Options for analysis running.
run:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 04047329a561..cf1880792630 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,13 @@
Follow the news and releases on our [twitter](https://twitter.com/golangci) and our [blog](https://medium.com/golangci).
There is the most valuable changes log:
+### v1.46.1
+
+1. updated linters:
+ * `execinquery`: bump from v0.6.0 to v0.6.1
+2. documentation:
+ * add missing linters
+
### v1.46.0
1. new linters:
diff --git a/README.md b/README.md
index 61f1cf619f3d..02bb45ac9f76 100644
--- a/README.md
+++ b/README.md
@@ -83,19 +83,19 @@ The Core Team has the following responsibilities:
 David Lobe |
-  sivchari |
+  sivchari |
 Alexey Palazhchenko |
 Duco van Amstel |
+  @golangci-releaser |
 Nishanth Shanmugham |
 Kensei Nakada |
-  @golangci-releaser |
 Melvin |
 Denis Krivak |
 Iskander (Alex) Sharipov |
-  Maik Schreiber |
 Steve Coffman |
+  Maik Schreiber |
 Matouš Dzivjak |
 Alec Thomas |
@@ -111,7 +111,7 @@ The Core Team has the following responsibilities:
-And 306 more our team members
+And 309 more our team members
diff --git a/assets/github-action-config.json b/assets/github-action-config.json
index b9452ec46396..aba0238cc303 100644
--- a/assets/github-action-config.json
+++ b/assets/github-action-config.json
@@ -1,8 +1,8 @@
{
"MinorVersionToConfig": {
"latest": {
- "TargetVersion": "v1.46.0",
- "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.46.0/golangci-lint-1.46.0-linux-amd64.tar.gz"
+ "TargetVersion": "v1.46.1",
+ "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.46.1/golangci-lint-1.46.1-linux-amd64.tar.gz"
},
"v1.10": {
"Error": "golangci-lint version 'v1.10' isn't supported: we support only v1.14.0 and later versions"
@@ -151,8 +151,8 @@
"AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.45.2/golangci-lint-1.45.2-linux-amd64.tar.gz"
},
"v1.46": {
- "TargetVersion": "v1.46.0",
- "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.46.0/golangci-lint-1.46.0-linux-amd64.tar.gz"
+ "TargetVersion": "v1.46.1",
+ "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.46.1/golangci-lint-1.46.1-linux-amd64.tar.gz"
},
"v1.5": {
"Error": "golangci-lint version 'v1.5' isn't supported: we support only v1.14.0 and later versions"
diff --git a/docs/src/docs/contributing/faq.mdx b/docs/src/docs/contributing/faq.mdx
index 05ca5e459848..9ed95b77dba2 100644
--- a/docs/src/docs/contributing/faq.mdx
+++ b/docs/src/docs/contributing/faq.mdx
@@ -21,7 +21,7 @@ Just update it's version in `go.mod`.
## How to add configuration option to existing linter
Add a new field to a [config struct](https://github.com/golangci/golangci-lint/blob/master/pkg/config/config.go).
-Document it in [.golangci.example.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml).
+Document it in [.golangci.reference.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml).
Pass it to a linter.
## How to see `INFO` or `DEBUG` logs
diff --git a/docs/src/docs/contributing/new-linters.mdx b/docs/src/docs/contributing/new-linters.mdx
index 23494f2bb5da..ec38b2671791 100644
--- a/docs/src/docs/contributing/new-linters.mdx
+++ b/docs/src/docs/contributing/new-linters.mdx
@@ -26,9 +26,9 @@ After that:
to the function `GetAllSupportedLinterConfigs`.
- Add `WithSince("next_version")`, where `next_version` must be replaced by the next minor version. (ex: v1.2.0 if the current version is v1.1.0)
4. Find out what options do you need to configure for the linter.
- For example, `nakedret` has only 1 option: [`max-func-lines`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml).
+ For example, `nakedret` has only 1 option: [`max-func-lines`](https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml).
Choose default values to not being annoying for users of golangci-lint. Add configuration options to:
- - [.golangci.example.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) - the example of a configuration file.
+ - [.golangci.reference.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml) - the example of a configuration file.
You can also add them to [.golangci.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.yml)
if you think that this project needs not default values.
- [config struct](https://github.com/golangci/golangci-lint/blob/master/pkg/config/config.go) -
diff --git a/docs/src/docs/contributing/workflow.mdx b/docs/src/docs/contributing/workflow.mdx
index e609cb666576..e565a4e5bb78 100644
--- a/docs/src/docs/contributing/workflow.mdx
+++ b/docs/src/docs/contributing/workflow.mdx
@@ -37,7 +37,7 @@ Which runs all the linters and tests.
## Create or update parameters for docs
-Add your new or updated parameters to `.golangci.example.yml` so they will be shown in the docs
+Add your new or updated parameters to `.golangci.reference.yml` so they will be shown in the docs
## Submit a pull request
diff --git a/docs/src/docs/usage/configuration.mdx b/docs/src/docs/usage/configuration.mdx
index 1a1102be34ac..8b4d0e735a28 100644
--- a/docs/src/docs/usage/configuration.mdx
+++ b/docs/src/docs/usage/configuration.mdx
@@ -28,7 +28,7 @@ To see which config file is being used and where it was sourced from run golangc
Config options inside the file are identical to command-line options.
You can configure specific linters' options only within the config file (not the command-line).
-There is a [`.golangci.example.yml`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) file with all supported options, their description, and default values.
+There is a [`.golangci.reference.yml`](https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml) file with all supported options, their description, and default values.
This file is a neither a working example nor recommended configuration, it's just a reference to display all the configuration options.
{ .ConfigurationExample }
diff --git a/docs/template_data.state b/docs/template_data.state
index 77f98814d915..e2817bdbf090 100755
--- a/docs/template_data.state
+++ b/docs/template_data.state
@@ -1,2 +1,2 @@
This file stores hash of website templates to trigger Netlify rebuild when something changes, e.g. new linter is added.
-8cfd07149636256f43111a5ce9fe44e52e233c0f90faa14f9e1d78dc91c980ef
\ No newline at end of file
+d3273f2bb8e834b6d8b6b290ad9703e80d06df1d34f33a3e7f9b24afd83b3b56
\ No newline at end of file
diff --git a/go.mod b/go.mod
index 40677c37dba0..410fb6ac26c1 100644
--- a/go.mod
+++ b/go.mod
@@ -54,7 +54,7 @@ require (
github.com/ldez/gomoddirectives v0.2.3
github.com/ldez/tagliatelle v0.3.1
github.com/leonklingele/grouper v1.1.0
- github.com/lufeee/execinquery v1.2.0
+ github.com/lufeee/execinquery v1.2.1
github.com/maratori/testpackage v1.0.1
github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // v1.0
github.com/mattn/go-colorable v0.1.12
@@ -67,7 +67,7 @@ require (
github.com/nishanths/exhaustive v0.7.11
github.com/nishanths/predeclared v0.2.2
github.com/pkg/errors v0.9.1
- github.com/polyfloyd/go-errorlint v0.0.0-20211125173453-6d6d39c5bb8b
+ github.com/polyfloyd/go-errorlint v1.0.0
github.com/quasilyte/go-ruleguard/dsl v0.3.19
github.com/ryancurrah/gomodguard v1.2.3
github.com/ryanrolds/sqlclosecheck v0.3.0
diff --git a/go.sum b/go.sum
index da56c4e7fed8..c0e92b283a69 100644
--- a/go.sum
+++ b/go.sum
@@ -503,8 +503,8 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
-github.com/lufeee/execinquery v1.2.0 h1:07LBuxOFCLoNXUuwnRxL1T+ef8rI0gYZRBe2yh9BflU=
-github.com/lufeee/execinquery v1.2.0/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM=
+github.com/lufeee/execinquery v1.2.1 h1:hf0Ems4SHcUGBxpGN7Jz78z1ppVkP/837ZlETPCEtOM=
+github.com/lufeee/execinquery v1.2.1/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
@@ -636,8 +636,8 @@ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qR
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/polyfloyd/go-errorlint v0.0.0-20211125173453-6d6d39c5bb8b h1:/BDyEJWLnDUYKGWdlNx/82qSaVu2bUok/EvPUtIGuvw=
-github.com/polyfloyd/go-errorlint v0.0.0-20211125173453-6d6d39c5bb8b/go.mod h1:wi9BfjxjF/bwiZ701TzmfKu6UKC357IOAtNr0Td0Lvw=
+github.com/polyfloyd/go-errorlint v1.0.0 h1:pDrQG0lrh68e602Wfp68BlUTRFoHn8PZYAjLgt2LFsM=
+github.com/polyfloyd/go-errorlint v1.0.0/go.mod h1:KZy4xxPJyy88/gldCe5OdW6OQRtNO3EZE7hXzmnebgA=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go
index cb4095d03aae..3d47951783f3 100644
--- a/pkg/config/linters_settings.go
+++ b/pkg/config/linters_settings.go
@@ -550,26 +550,16 @@ type TestpackageSettings struct {
}
type ThelperSettings struct {
- Test struct {
- First bool `mapstructure:"first"`
- Name bool `mapstructure:"name"`
- Begin bool `mapstructure:"begin"`
- } `mapstructure:"test"`
- Fuzz struct {
- First bool `mapstructure:"first"`
- Name bool `mapstructure:"name"`
- Begin bool `mapstructure:"begin"`
- } `mapstructure:"fuzz"`
- Benchmark struct {
- First bool `mapstructure:"first"`
- Name bool `mapstructure:"name"`
- Begin bool `mapstructure:"begin"`
- } `mapstructure:"benchmark"`
- TB struct {
- First bool `mapstructure:"first"`
- Name bool `mapstructure:"name"`
- Begin bool `mapstructure:"begin"`
- } `mapstructure:"tb"`
+ Test ThelperOptions `mapstructure:"test"`
+ Fuzz ThelperOptions `mapstructure:"fuzz"`
+ Benchmark ThelperOptions `mapstructure:"benchmark"`
+ TB ThelperOptions `mapstructure:"tb"`
+}
+
+type ThelperOptions struct {
+ First *bool `mapstructure:"first"`
+ Name *bool `mapstructure:"name"`
+ Begin *bool `mapstructure:"begin"`
}
type TenvSettings struct {
diff --git a/pkg/golinters/thelper.go b/pkg/golinters/thelper.go
index 349c46666df6..41edbe7616fd 100644
--- a/pkg/golinters/thelper.go
+++ b/pkg/golinters/thelper.go
@@ -13,53 +13,44 @@ import (
func NewThelper(cfg *config.ThelperSettings) *goanalysis.Linter {
a := analyzer.NewAnalyzer()
- cfgMap := map[string]map[string]interface{}{}
- if cfg != nil {
- var opts []string
+ opts := map[string]struct{}{
+ "t_name": {},
+ "t_begin": {},
+ "t_first": {},
- if cfg.Test.Name {
- opts = append(opts, "t_name")
- }
- if cfg.Test.Begin {
- opts = append(opts, "t_begin")
- }
- if cfg.Test.First {
- opts = append(opts, "t_first")
- }
+ "f_name": {},
+ "f_begin": {},
+ "f_first": {},
- if cfg.Fuzz.Name {
- opts = append(opts, "f_name")
- }
- if cfg.Fuzz.Begin {
- opts = append(opts, "f_begin")
- }
- if cfg.Fuzz.First {
- opts = append(opts, "f_first")
- }
+ "b_name": {},
+ "b_begin": {},
+ "b_first": {},
- if cfg.Benchmark.Name {
- opts = append(opts, "b_name")
- }
- if cfg.Benchmark.Begin {
- opts = append(opts, "b_begin")
- }
- if cfg.Benchmark.First {
- opts = append(opts, "b_first")
- }
+ "tb_name": {},
+ "tb_begin": {},
+ "tb_first": {},
+ }
- if cfg.TB.Name {
- opts = append(opts, "tb_name")
- }
- if cfg.TB.Begin {
- opts = append(opts, "tb_begin")
- }
- if cfg.TB.First {
- opts = append(opts, "tb_first")
- }
+ if cfg != nil {
+ applyTHelperOptions(cfg.Test, "t_", opts)
+ applyTHelperOptions(cfg.Fuzz, "f_", opts)
+ applyTHelperOptions(cfg.Benchmark, "b_", opts)
+ applyTHelperOptions(cfg.TB, "tb_", opts)
+ }
- cfgMap[a.Name] = map[string]interface{}{
- "checks": strings.Join(opts, ","),
- }
+ if len(opts) == 0 {
+ linterLogger.Fatalf("thelper: at least one option must be enabled")
+ }
+
+ var args []string
+ for k := range opts {
+ args = append(args, k)
+ }
+
+ cfgMap := map[string]map[string]interface{}{
+ a.Name: {
+ "checks": strings.Join(args, ","),
+ },
}
return goanalysis.NewLinter(
@@ -69,3 +60,23 @@ func NewThelper(cfg *config.ThelperSettings) *goanalysis.Linter {
cfgMap,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}
+
+func applyTHelperOptions(o config.ThelperOptions, prefix string, opts map[string]struct{}) {
+ if o.Name != nil {
+ if !*o.Name {
+ delete(opts, prefix+"name")
+ }
+ }
+
+ if o.Begin != nil {
+ if !*o.Begin {
+ delete(opts, prefix+"begin")
+ }
+ }
+
+ if o.First != nil {
+ if !*o.First {
+ delete(opts, prefix+"first")
+ }
+ }
+}
diff --git a/scripts/expand_website_templates/main.go b/scripts/expand_website_templates/main.go
index c3247c8cd26e..ca29f251ab2b 100644
--- a/scripts/expand_website_templates/main.go
+++ b/scripts/expand_website_templates/main.go
@@ -164,14 +164,14 @@ func getLatestVersion() (string, error) {
}
func buildTemplateContext() (map[string]string, error) {
- golangciYamlExample, err := os.ReadFile(".golangci.example.yml")
+ golangciYamlExample, err := os.ReadFile(".golangci.reference.yml")
if err != nil {
- return nil, fmt.Errorf("can't read .golangci.example.yml: %w", err)
+ return nil, fmt.Errorf("can't read .golangci.reference.yml: %w", err)
}
snippets, err := extractExampleSnippets(golangciYamlExample)
if err != nil {
- return nil, fmt.Errorf("can't read .golangci.example.yml: %w", err)
+ return nil, fmt.Errorf("can't read .golangci.reference.yml: %w", err)
}
if err = exec.Command("make", "build").Run(); err != nil {
diff --git a/scripts/expand_website_templates/main_test.go b/scripts/expand_website_templates/main_test.go
index 24afffb8b59b..c6e36e1ba3f9 100644
--- a/scripts/expand_website_templates/main_test.go
+++ b/scripts/expand_website_templates/main_test.go
@@ -10,7 +10,7 @@ import (
func Test_extractExampleSnippets(t *testing.T) {
t.Skip("only for debugging purpose")
- example, err := os.ReadFile("../../../golangci-lint/.golangci.example.yml")
+ example, err := os.ReadFile("../../../golangci-lint/.golangci.reference.yml")
require.NoError(t, err)
m, err := extractExampleSnippets(example)
diff --git a/test/testdata/configs/thelper.yml b/test/testdata/configs/thelper.yml
new file mode 100644
index 000000000000..eaa8f403b206
--- /dev/null
+++ b/test/testdata/configs/thelper.yml
@@ -0,0 +1,5 @@
+linters-settings:
+ thelper:
+ test:
+ name: false
+ begin: true
diff --git a/test/testdata/thelper_with_options.go b/test/testdata/thelper_with_options.go
new file mode 100644
index 000000000000..da835b536164
--- /dev/null
+++ b/test/testdata/thelper_with_options.go
@@ -0,0 +1,18 @@
+// args: -Ethelper
+// config_path: testdata/configs/thelper.yml
+package testdata
+
+import "testing"
+
+func thelperWithHelperAfterAssignmentWO(t *testing.T) { // ERROR "test helper function should start from t.Helper()"
+ _ = 0
+ t.Helper()
+}
+
+func thelperWithNotFirstWO(s string, t *testing.T, i int) { // ERROR `parameter \*testing.T should be the first`
+ t.Helper()
+}
+
+func thelperWithIncorrectNameWO(o *testing.T) {
+ o.Helper()
+}