Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump github.com/kulti/thelper from 0.5.1 to 0.6.2 #2742

Merged
merged 1 commit into from Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -46,7 +46,7 @@ require (
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af
github.com/julz/importas v0.1.0
github.com/kisielk/errcheck v1.6.0
github.com/kulti/thelper v0.5.1
github.com/kulti/thelper v0.6.2
github.com/kunwardeep/paralleltest v1.0.3
github.com/kyoh86/exportloopref v0.1.8
github.com/ldez/gomoddirectives v0.2.2
Expand Down
6 changes: 2 additions & 4 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/config/linters_settings.go
Expand Up @@ -549,6 +549,11 @@ type ThelperSettings struct {
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"`
Expand Down
10 changes: 10 additions & 0 deletions pkg/golinters/thelper.go
Expand Up @@ -27,6 +27,16 @@ func NewThelper(cfg *config.ThelperSettings) *goanalysis.Linter {
opts = append(opts, "t_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")
}

if cfg.Benchmark.Name {
opts = append(opts, "b_name")
}
Expand Down
25 changes: 25 additions & 0 deletions test/testdata/thelper_go118.go
@@ -0,0 +1,25 @@
//go:build go1.18
// +build go1.18

//args: -Ethelper
package testdata

import "testing"

func fhelperWithHelperAfterAssignment(f *testing.F) { // ERROR "test helper function should start from f.Helper()"
_ = 0
f.Helper()
}

func fhelperWithNotFirst(s string, f *testing.F, i int) { // ERROR `parameter \*testing.F should be the first`
f.Helper()
}

func fhelperWithIncorrectName(o *testing.F) { // ERROR `parameter \*testing.F should have name f`
o.Helper()
}

func FuzzSubtestShouldNotBeChecked(f *testing.F) {
f.Add(5, "hello")
f.Fuzz(func(t *testing.T, a int, b string) {})
}