From 2ead64dba1ed6c672e441b802b4607afb5b687fe Mon Sep 17 00:00:00 2001 From: sivchari Date: Fri, 17 Sep 2021 22:24:15 +0900 Subject: [PATCH] delete check conditions --- .golangci.example.yml | 2 - go.mod | 2 +- go.sum | 6 +-- pkg/config/linters_settings.go | 3 +- pkg/golinters/tenv.go | 1 - .../{tenv_all_force.yml => tenv_all.yml} | 1 - test/testdata/configs/tenv_force.yml | 3 -- ...env_all_force_test.go => tenv_all_test.go} | 2 +- test/testdata/tenv_force_test.go | 41 ------------------- test/testdata/tenv_test.go | 12 +++--- 10 files changed, 11 insertions(+), 62 deletions(-) rename test/testdata/configs/{tenv_all_force.yml => tenv_all.yml} (71%) delete mode 100644 test/testdata/configs/tenv_force.yml rename test/testdata/{tenv_all_force_test.go => tenv_all_test.go} (95%) delete mode 100644 test/testdata/tenv_force_test.go diff --git a/.golangci.example.yml b/.golangci.example.yml index 60c84856587f..3a77079abbd4 100644 --- a/.golangci.example.yml +++ b/.golangci.example.yml @@ -623,8 +623,6 @@ linters-settings: begin: true tenv: - # The following configurations enable checks prior to Go 1.17. - force: false # The all option will run against all method in test file. # By default, only methods that take *testing.T, *testing.B, and testing.TB as arguments are checked. all: false diff --git a/go.mod b/go.mod index 2ddea7afd68a..5a66928f89b6 100644 --- a/go.mod +++ b/go.mod @@ -69,7 +69,7 @@ require ( github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c github.com/shirou/gopsutil/v3 v3.21.8 github.com/sirupsen/logrus v1.8.1 - github.com/sivchari/tenv v1.1.6 + github.com/sivchari/tenv v1.2.6 github.com/sonatard/noctx v0.0.1 github.com/sourcegraph/go-diff v0.6.1 github.com/spf13/cobra v1.2.1 diff --git a/go.sum b/go.sum index 8b4a9cd6e7e2..87214b303727 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,6 @@ contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EU dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Antonboom/errname v0.1.4 h1:lGSlI42Gm4bI1e+IITtXJXvxFM8N7naWimVFKcb0McY= github.com/Antonboom/errname v0.1.4/go.mod h1:jRXo3m0E0EuCnK3wbsSVH3X55Z4iTDLl6ZfCxwFj4TM= -github.com/Antonboom/nilnil v0.0.0-20210914182304-d33f75a9101c h1:GZ/bAqfmHdiHy8O0jwbGwLsK0qyw+8iuCaqNbCcV/to= -github.com/Antonboom/nilnil v0.0.0-20210914182304-d33f75a9101c/go.mod h1:PhHLvRPSghY5Y7mX4TW+BHZQYo1A8flE5H20D3IPZBo= github.com/Antonboom/nilnil v0.1.0 h1:DLDavmg0a6G/F4Lt9t7Enrbgb3Oph6LnDE6YVsmTt74= github.com/Antonboom/nilnil v0.1.0/go.mod h1:PhHLvRPSghY5Y7mX4TW+BHZQYo1A8flE5H20D3IPZBo= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -634,8 +632,8 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sivchari/tenv v1.1.6 h1:MQLDdDZwfr3IEmNFdN9VFKStp02RTEZqa0G5zlIcc1c= -github.com/sivchari/tenv v1.1.6/go.mod h1:5nF+bITvkebQVanjU6IuMbvIot/7ReNsUV7I5NbprB0= +github.com/sivchari/tenv v1.2.6 h1:OveRTnUsGqP65AaPBggmsdThsy5EpQcYakaTntauRAw= +github.com/sivchari/tenv v1.2.6/go.mod h1:5nF+bITvkebQVanjU6IuMbvIot/7ReNsUV7I5NbprB0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index ed42ec4bdbb0..9c647616351e 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -460,8 +460,7 @@ type ThelperSettings struct { } type TenvSettings struct { - Force bool `mapstructure:"force"` - All bool `mapstructure:"all"` + All bool `mapstructure:"all"` } type UnparamSettings struct { diff --git a/pkg/golinters/tenv.go b/pkg/golinters/tenv.go index 41313ef46f6e..8e3e9c61f601 100644 --- a/pkg/golinters/tenv.go +++ b/pkg/golinters/tenv.go @@ -19,7 +19,6 @@ func NewTenv(settings *config.TenvSettings) *goanalysis.Linter { if settings != nil { cfg = map[string]map[string]interface{}{ a.Name: { - tenv.F: settings.Force, tenv.A: settings.All, }, } diff --git a/test/testdata/configs/tenv_all_force.yml b/test/testdata/configs/tenv_all.yml similarity index 71% rename from test/testdata/configs/tenv_all_force.yml rename to test/testdata/configs/tenv_all.yml index 29fd3dc2d043..f0ae4fd226c4 100644 --- a/test/testdata/configs/tenv_all_force.yml +++ b/test/testdata/configs/tenv_all.yml @@ -1,4 +1,3 @@ linters-settings: tenv: - force: true all: true diff --git a/test/testdata/configs/tenv_force.yml b/test/testdata/configs/tenv_force.yml deleted file mode 100644 index 7ec079ba9581..000000000000 --- a/test/testdata/configs/tenv_force.yml +++ /dev/null @@ -1,3 +0,0 @@ -linters-settings: - tenv: - force: true diff --git a/test/testdata/tenv_all_force_test.go b/test/testdata/tenv_all_test.go similarity index 95% rename from test/testdata/tenv_all_force_test.go rename to test/testdata/tenv_all_test.go index 772356e9e440..babdd134a180 100644 --- a/test/testdata/tenv_all_force_test.go +++ b/test/testdata/tenv_all_test.go @@ -1,5 +1,5 @@ // args: -Etenv -// config_path: testdata/configs/tenv_all_force.yml +// config_path: testdata/configs/tenv_all.yml package testdata import ( diff --git a/test/testdata/tenv_force_test.go b/test/testdata/tenv_force_test.go deleted file mode 100644 index 01ee5dda1e58..000000000000 --- a/test/testdata/tenv_force_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// args: -Etenv -// config_path: testdata/configs/tenv_force.yml -package testdata - -import ( - "os" - "testing" -) - -var ( - e = os.Setenv("a", "b") // OK -) - -func setup() { - os.Setenv("a", "b") // OK - err := os.Setenv("a", "b") // OK - if err != nil { - _ = err - } -} - -func TestF(t *testing.T) { - os.Setenv("a", "b") // ERROR "func TestF is not using testing.Setenv" - if err := os.Setenv("a", "b"); err != nil { // ERROR "func TestF is not using testing.Setenv" - _ = err - } -} - -func BenchmarkF(b *testing.B) { - os.Setenv("a", "b") // ERROR "func BenchmarkF is not using testing.Setenv" - if err := os.Setenv("a", "b"); err != nil { // ERROR "func BenchmarkF is not using testing.Setenv" - _ = err - } -} - -func testTB(tb testing.TB) { - os.Setenv("a", "b") // ERROR "func testTB is not using testing.Setenv" - if err := os.Setenv("a", "b"); err != nil { // ERROR "func testTB is not using testing.Setenv" - _ = err - } -} diff --git a/test/testdata/tenv_test.go b/test/testdata/tenv_test.go index 023ea68ed02d..d4f6c90d2d91 100644 --- a/test/testdata/tenv_test.go +++ b/test/testdata/tenv_test.go @@ -19,22 +19,22 @@ func setup() { } func TestF(t *testing.T) { - os.Setenv("a", "b") // OK - if err := os.Setenv("a", "b"); err != nil { // OK + os.Setenv("a", "b") // ERROR "func TestF is not using testing.Setenv" + if err := os.Setenv("a", "b"); err != nil { // ERROR "func TestF is not using testing.Setenv" _ = err } } func BenchmarkF(b *testing.B) { - os.Setenv("a", "b") // OK - if err := os.Setenv("a", "b"); err != nil { // OK + os.Setenv("a", "b") // ERROR "func BenchmarkF is not using testing.Setenv" + if err := os.Setenv("a", "b"); err != nil { // ERROR "func BenchmarkF is not using testing.Setenv" _ = err } } func testTB(tb testing.TB) { - os.Setenv("a", "b") // OK - if err := os.Setenv("a", "b"); err != nil { // OK + os.Setenv("a", "b") // ERROR "func testTB is not using testing.Setenv" + if err := os.Setenv("a", "b"); err != nil { // ERROR "func testTB is not using testing.Setenv" _ = err } }