Skip to content

Commit

Permalink
bump github.com/kulti/thelper from 0.5.1 to 0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kulti committed Apr 6, 2022
1 parent bb7731f commit faa3445
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
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.1
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) {})
}

0 comments on commit faa3445

Please sign in to comment.