From 86321a53d5eb4ac6d271708edff2f810d59ff939 Mon Sep 17 00:00:00 2001 From: golangci-releaser <65486276+golangci-releaser@users.noreply.github.com> Date: Thu, 12 May 2022 13:46:58 +0300 Subject: [PATCH 1/7] docs: Update documentation and assets (#2846) Co-authored-by: Fernandez Ludovic --- CHANGELOG.md | 7 ++++ README.md | 57 +++++++++++++++++--------------- assets/github-action-config.json | 8 ++--- docs/template_data.state | 2 +- 4 files changed, 43 insertions(+), 31 deletions(-) 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 @@ -136,36 +136,36 @@ The Core Team has the following responsibilities: + - + - + - + - @@ -224,26 +224,26 @@ The Core Team has the following responsibilities: + - + - + - @@ -358,120 +358,120 @@ The Core Team has the following responsibilities: + - + - + - + - + - + - + - + - + - + - + - + + - - + + - - @@ -505,7 +505,12 @@ The Core Team has the following responsibilities: + + + + +

Rski

sonatard

Aneesh Agrawal

Gustavo Bazan

Vladimir Evgrafov

ZhangYunHao

Anton Zinovyev

gaojingyu

gaojingyu

@odidev

NiseVoid

Sean DuBois

Viktoras

Florian Bosdorff

Agniva De Sarker

Eugene Simonov

Eugene Simonov

SystemGlitch

Henrik Johansson

Tom Arrell

Christian Mehlmauer

John Starich

Koichi Shiraishi

Bart

Bart

Neha Viswanathan

Oleksandr Redko

David Braley

Patrick Kuca

Viacheslav Poturaev

Gustavo Bazan

Lukas Malkmus

Ben Ye

lufe

Stephanie Wilde-Hobbs

Cory LaNou

Pete Wagner

Sindre Røkenes Myren

Jakub Chábek

Vitaly Isaev

Vitaly Isaev

Shulhan

Renato Suero

Ben Wells

Jonathan Chappelow

Brian Flad

Lauris BH

Sean McGinnis

Sean McGinnis

Eric Wohltman

Borja Clemente

lufe

masibw

Gianguido Sorà

Derek Perkins

Ryo Sato

Eric Zimanyi

Boban Acimovic

David Hill

Troy Ronda

Jared Allard

Osamu TONOMORI

Bo Liu

Steven Allen

Steven Allen

Colin Arnott

Eran Levy

Roman Leventov

Eric Jain

Hugo

Mathias Weber

Naveen

Naveen

Michael

Evgeniy Kulikov

Chris Nesbitt-Smith

Daniel Caballero

Carlton Henderson

Shintaro Ikeda

Matt Braymer-Hayes

Matt Braymer-Hayes

@ttys3

Tomas Dabasinskas

@xuri

Charl Matthee

Sriram Venkatesh

Peter Schuller

David Golub

David Golub

Alexander Morozov

@hbandura

Liam White

Alex Dupre

Juanito

Jinming Yue

Igor Zibarev

Igor Zibarev

@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

Stephen Brown II

Stephen Brown II

Matthew Cobbing

@Darlez

Kirill Danshin

mook

Kyungmin Bae

Dylan Arbour

@andreykuchin

@andreykuchin

Irina

Petr Pučil

Aaron Bennett

失眠是真滴难受

Dima

Alexandre Vilain

Thirukumaran Vaseeharan

Thirukumaran Vaseeharan

Alessio Treglia

Alay Patel

Martin Hutchinson

Emanuel Bennici

Mayo

Matias Lahti

Sebastian Crane

Sebastian Crane

Alexander Else

Vlado Pajić

Christian Clauss

Johanan Liebermann

Korjavin Ivan

Eng Zer Jun

Mateus Esdras

Mateus Esdras

Hilário Coelho

Tibo Delor

Francois Parquet

Robert Kopaczewski

Marc Tudurí

@opennota

Cyrille Meichel

neglect-yp

Cyrille Meichel

neglect-yp

Felix

Adrien

Joe Bergevin

Guillaume JG

Hilário Coelho

Eric Zimanyi

Anirudh Sylendranath

Axetroy

Arman Tarkhanian

John Adler

@licraft2019

@mlueckest

Lucas Ramage

Thomas Bonfort

Matthieu MOREL
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/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 From 9684688dc3250cf025afe920365b53f865b6fd9d Mon Sep 17 00:00:00 2001 From: sivchari Date: Fri, 13 May 2022 17:51:22 +0900 Subject: [PATCH 2/7] docs: add containedctx linter to the list of available linters (#2850) From e889b405dff8a71038c49d0a77f30782a8ae4804 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Sat, 14 May 2022 17:03:49 +0200 Subject: [PATCH 3/7] bump github.com/lufeee/execinquery from v1.2.0 to v1.2.1 (#2853) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 40677c37dba0..052cc7acfe5e 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 diff --git a/go.sum b/go.sum index da56c4e7fed8..07b84e34d4b4 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= From 4deb32f2c083b244f64993e8ff40c97b52bc513a Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 16 May 2022 12:26:25 +0200 Subject: [PATCH 4/7] docs: rename .golangci.example.yml to .golangci.reference.yml (#2857) --- .golangci.example.yml => .golangci.reference.yml | 3 +++ docs/src/docs/contributing/faq.mdx | 2 +- docs/src/docs/contributing/new-linters.mdx | 4 ++-- docs/src/docs/contributing/workflow.mdx | 2 +- docs/src/docs/usage/configuration.mdx | 2 +- scripts/expand_website_templates/main.go | 6 +++--- scripts/expand_website_templates/main_test.go | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) rename .golangci.example.yml => .golangci.reference.yml (99%) 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/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/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) From d8bf2434ec8ab19f9c754ffdd45ddacbe58a1e92 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 16 May 2022 21:07:11 +0200 Subject: [PATCH 5/7] bump github.com/polyfloyd/go-errorlint to v1.0.0 (#2855) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 052cc7acfe5e..410fb6ac26c1 100644 --- a/go.mod +++ b/go.mod @@ -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 07b84e34d4b4..c0e92b283a69 100644 --- a/go.sum +++ b/go.sum @@ -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= From b504325dc5e3b52dbed09826e3728d713b1f3efe Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 16 May 2022 21:16:25 +0200 Subject: [PATCH 6/7] thelper: allow to disable one option (#2854) --- pkg/config/linters_settings.go | 30 +++------ pkg/golinters/thelper.go | 95 +++++++++++++++------------ test/testdata/configs/thelper.yml | 5 ++ test/testdata/thelper_with_options.go | 18 +++++ 4 files changed, 86 insertions(+), 62 deletions(-) create mode 100644 test/testdata/configs/thelper.yml create mode 100644 test/testdata/thelper_with_options.go 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/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() +} From a3336890904cd3efa4f1c7e3f82ce207fe125a6f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 09:05:08 +0300 Subject: [PATCH 7/7] build(deps): bump golangci/golangci-lint-action from 3.1.0 to 3.2.0 (#2858) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.1.0...v3.2.0) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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