From 8de59a325791e1a369ec67d2b37ab783920ae19b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:44:44 +0200 Subject: [PATCH 1/5] build(deps): bump github.com/maratori/testpackage from 1.0.1 to 1.1.0 (#2945) Co-authored-by: Fernandez Ludovic --- go.mod | 1 + go.sum | 8 ++------ pkg/golinters/nosnakecase.go | 19 +++++++++++++++++++ pkg/lint/lintersdb/manager.go | 5 +++++ test/testdata/nosnakecase.go | 18 ++++++++++++++++++ 5 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 pkg/golinters/nosnakecase.go create mode 100644 test/testdata/nosnakecase.go diff --git a/go.mod b/go.mod index 6b3c1997a06e..5e87d359c44d 100644 --- a/go.mod +++ b/go.mod @@ -155,6 +155,7 @@ require ( github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect + github.com/sivchari/nosnakecase v1.0.1 github.com/spf13/afero v1.8.2 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect diff --git a/go.sum b/go.sum index 5fcbca7e5bb1..153168370d21 100644 --- a/go.sum +++ b/go.sum @@ -617,6 +617,8 @@ github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sivchari/containedctx v1.0.2 h1:0hLQKpgC53OVF1VT7CeoFHk9YKstur1XOgfYIc1yrHI= github.com/sivchari/containedctx v1.0.2/go.mod h1:PwZOeqm4/DLoJOqMSIJs3aKqXRX4YO+uXww087KZ7Bw= +github.com/sivchari/nosnakecase v1.0.1 h1:ziZkXTPHCofuoB5DaozlkrU9+15PbnKxn7D7v67Xi4A= +github.com/sivchari/nosnakecase v1.0.1/go.mod h1:CwDzrzPea40/GB6uynrNLiorAlgFRvRbFSgJx2Gs+QY= github.com/sivchari/tenv v1.6.0 h1:FyE4WysxLwYljKqWhTfOMjgKjBSnmzzg7lWOmpDiAcc= github.com/sivchari/tenv v1.6.0/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -671,17 +673,11 @@ github.com/sylvia7788/contextcheck v1.0.4/go.mod h1:vuPKJMQ7MQ91ZTqfdyreNKwZjyUg github.com/tdakkota/asciicheck v0.1.1 h1:PKzG7JUTUmVspQTDqtkX9eSiLGossXTybutHwTXuO0A= github.com/tdakkota/asciicheck v0.1.1/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM= github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= -github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= -github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= -github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= -github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= -github.com/tetafro/godot v1.4.11 h1:BVoBIqAf/2QdbFmSwAWnaIqDivZdOV0ZRwEm6jivLKw= github.com/tetafro/godot v1.4.11 h1:BVoBIqAf/2QdbFmSwAWnaIqDivZdOV0ZRwEm6jivLKw= github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8= -github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8= github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 h1:kl4KhGNsJIbDHS9/4U9yQo1UcPQM0kOMJHn29EoH/Ro= github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk= github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= diff --git a/pkg/golinters/nosnakecase.go b/pkg/golinters/nosnakecase.go new file mode 100644 index 000000000000..26d5d6d4c84f --- /dev/null +++ b/pkg/golinters/nosnakecase.go @@ -0,0 +1,19 @@ +package golinters + +import ( + "github.com/sivchari/nosnakecase" + "golang.org/x/tools/go/analysis" + + "github.com/golangci/golangci-lint/pkg/golinters/goanalysis" +) + +func NewNoSnakeCase() *goanalysis.Linter { + a := nosnakecase.Analyzer + + return goanalysis.NewLinter( + a.Name, + a.Doc, + []*analysis.Analyzer{a}, + nil, + ).WithLoadMode(goanalysis.LoadModeSyntax) +} diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index e6c069b7f56f..4c8f74fb7c88 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -631,6 +631,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithPresets(linter.PresetStyle). WithURL("https://github.com/firefart/nonamedreturns"), + linter.NewConfig(golinters.NewNoSnakeCase()). + WithSince("v1.46.0"). + WithPresets(linter.PresetStyle). + WithURL("https://github.com/sivchari/nosnakecase"), + linter.NewConfig(golinters.NewNoSprintfHostPort()). WithSince("v1.46.0"). WithPresets(linter.PresetStyle). diff --git a/test/testdata/nosnakecase.go b/test/testdata/nosnakecase.go new file mode 100644 index 000000000000..75d81c7b2975 --- /dev/null +++ b/test/testdata/nosnakecase.go @@ -0,0 +1,18 @@ +// args: -Enosnakecase +package testdata + +func a_() { // ERROR "a_ is used under score. You should use mixedCap or MixedCap." +} + +func b(a_a int) { // ERROR "a_a is used under score. You should use mixedCap or MixedCap." +} + +func c() (c_c int) { // ERROR "c_c is used under score. You should use mixedCap or MixedCap." + c_c = 1 // ERROR "c_c is used under score. You should use mixedCap or MixedCap." + return c_c // It's never detected, because `c_c` is already detected. +} + +func d() { + var d_d int // ERROR "d_d is used under score. You should use mixedCap or MixedCap." + _ = d_d // It's never detected, because `_` is meaningful in Go and `d_d` is already detected. +} From 834071a155fa88853398a64b084322d2cfdeeaff Mon Sep 17 00:00:00 2001 From: sivchari Date: Wed, 29 Jun 2022 00:42:56 +0900 Subject: [PATCH 2/5] fix conflict --- go.mod | 2 +- go.sum | 4 +- test/testdata/nosnakecase.go | 149 ++++++++++++++++++++++++++++++++--- 3 files changed, 143 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 5e87d359c44d..f7dc42ae6cf4 100644 --- a/go.mod +++ b/go.mod @@ -155,7 +155,7 @@ require ( github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect - github.com/sivchari/nosnakecase v1.0.1 + github.com/sivchari/nosnakecase v1.5.0 github.com/spf13/afero v1.8.2 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect diff --git a/go.sum b/go.sum index 153168370d21..64527bf4e018 100644 --- a/go.sum +++ b/go.sum @@ -617,8 +617,8 @@ github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sivchari/containedctx v1.0.2 h1:0hLQKpgC53OVF1VT7CeoFHk9YKstur1XOgfYIc1yrHI= github.com/sivchari/containedctx v1.0.2/go.mod h1:PwZOeqm4/DLoJOqMSIJs3aKqXRX4YO+uXww087KZ7Bw= -github.com/sivchari/nosnakecase v1.0.1 h1:ziZkXTPHCofuoB5DaozlkrU9+15PbnKxn7D7v67Xi4A= -github.com/sivchari/nosnakecase v1.0.1/go.mod h1:CwDzrzPea40/GB6uynrNLiorAlgFRvRbFSgJx2Gs+QY= +github.com/sivchari/nosnakecase v1.5.0 h1:ZBvAu1H3uteN0KQ0IsLpIFOwYgPEhKLyv2ahrVkub6M= +github.com/sivchari/nosnakecase v1.5.0/go.mod h1:CwDzrzPea40/GB6uynrNLiorAlgFRvRbFSgJx2Gs+QY= github.com/sivchari/tenv v1.6.0 h1:FyE4WysxLwYljKqWhTfOMjgKjBSnmzzg7lWOmpDiAcc= github.com/sivchari/tenv v1.6.0/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= diff --git a/test/testdata/nosnakecase.go b/test/testdata/nosnakecase.go index 75d81c7b2975..2d6374528660 100644 --- a/test/testdata/nosnakecase.go +++ b/test/testdata/nosnakecase.go @@ -1,18 +1,149 @@ -// args: -Enosnakecase +//args: -Enosnakecase package testdata -func a_() { // ERROR "a_ is used under score. You should use mixedCap or MixedCap." +import ( + _ "fmt" + f_m_t "fmt" // ERROR "f_m_t is used under score. You should use mixedCap or MixedCap." +) + +// global variable name with underscore. +var v_v = 0 // ERROR "v_v is used under score. You should use mixedCap or MixedCap." + +// global constant name with underscore. +const c_c = 0 // ERROR "c_c is used under score. You should use mixedCap or MixedCap." + +// struct name with underscore. +type S_a struct { // ERROR "S_a is used under score. You should use mixedCap or MixedCap." + fi int +} + +// non-exported struct field name with underscore. +type Sa struct { + fi_a int // // ERROR "fi_a is used under score. You should use mixedCap or MixedCap." +} + +// function as struct field, with parameter name with underscore. +type Sb struct { + fib func(p_a int) // ERROR "p_a is used under score. You should use mixedCap or MixedCap." +} + +// exported struct field with underscore. +type Sc struct { + Fi_A int // ERROR "Fi_A is used under score. You should use mixedCap or MixedCap." +} + +// function as struct field, with return name with underscore. +type Sd struct { + fib func(p int) (r_a int) // ERROR "r_a is used under score. You should use mixedCap or MixedCap." +} + +// interface name with underscore. +type I_a interface { // ERROR "I_a is used under score. You should use mixedCap or MixedCap." + fn(p int) } -func b(a_a int) { // ERROR "a_a is used under score. You should use mixedCap or MixedCap." +// interface with parameter name with underscore. +type Ia interface { + fn(p_a int) // ERROR "p_a is used under score. You should use mixedCap or MixedCap." } -func c() (c_c int) { // ERROR "c_c is used under score. You should use mixedCap or MixedCap." - c_c = 1 // ERROR "c_c is used under score. You should use mixedCap or MixedCap." - return c_c // It's never detected, because `c_c` is already detected. +// interface with parameter name with underscore. +type Ib interface { + Fn(p_a int) // ERROR "p_a is used under score. You should use mixedCap or MixedCap." } -func d() { - var d_d int // ERROR "d_d is used under score. You should use mixedCap or MixedCap." - _ = d_d // It's never detected, because `_` is meaningful in Go and `d_d` is already detected. +// function as struct field, with return name with underscore. +type Ic interface { + Fn_a() // ERROR "Fn_a is used under score. You should use mixedCap or MixedCap." +} + +// interface with return name with underscore. +type Id interface { + Fn() (r_a int) // ERROR "r_a is used under score. You should use mixedCap or MixedCap." +} + +// function name with underscore. +func f_a() {} // ERROR "f_a is used under score. You should use mixedCap or MixedCap." + +// function's parameter name with underscore. +func fb(p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + +// named return with underscore. +func fc() (r_b int) { // ERROR "r_b is used under score. You should use mixedCap or MixedCap." + return 0 +} + +// local variable (short declaration) with underscore. +func fd(p int) int { + v_b := p * 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + + return v_b // ERROR "v_b is used under score. You should use mixedCap or MixedCap." +} + +// local constant with underscore. +func fe(p int) int { + const v_b = 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + + return v_b * p // ERROR "v_b is used under score. You should use mixedCap or MixedCap." +} + +// local variable with underscore. +func ff(p int) int { + var v_b = 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + + return v_b * p // ERROR "v_b is used under score. You should use mixedCap or MixedCap." +} + +// inner function, parameter name with underscore. +func fg() { + fgl := func(p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + fgl(1) +} + +type Foo struct{} + +// method name with underscore. +func (f Foo) f_a() {} // ERROR "f_a is used under score. You should use mixedCap or MixedCap." + +// method's parameter name with underscore. +func (f Foo) fb(p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + +// named return with underscore. +func (f Foo) fc() (r_b int) { return 0 } // ERROR "r_b is used under score. You should use mixedCap or MixedCap." + +// local variable (short declaration) with underscore. +func (f Foo) fd(p int) int { + v_b := p * 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + + return v_b // ERROR "v_b is used under score. You should use mixedCap or MixedCap." +} + +// local constant with underscore. +func (f Foo) fe(p int) int { + const v_b = 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + + return v_b * p // ERROR "v_b is used under score. You should use mixedCap or MixedCap." +} + +// local variable with underscore. +func (f Foo) ff(p int) int { + var v_b = 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + + return v_b * p // ERROR "v_b is used under score. You should use mixedCap or MixedCap." +} + +func fna(a, p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + +func fna1(a string, p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + +func fnb(a, b, p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + +func fnb1(a, b string, p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + +func fnd( + p_a int, // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + p_b int, // ERROR "p_b is used under score. You should use mixedCap or MixedCap." + p_c int, // ERROR "p_c is used under score. You should use mixedCap or MixedCap." +) { + f_m_t.Println("") // ERROR "f_m_t is used under score. You should use mixedCap or MixedCap." } From 54b0d3f78b83f94a0f8c61f960b2fdba623f8828 Mon Sep 17 00:00:00 2001 From: sivchari Date: Wed, 29 Jun 2022 00:46:47 +0900 Subject: [PATCH 3/5] fix report message --- test/testdata/nosnakecase.go | 80 ++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/test/testdata/nosnakecase.go b/test/testdata/nosnakecase.go index 2d6374528660..d52c474dd057 100644 --- a/test/testdata/nosnakecase.go +++ b/test/testdata/nosnakecase.go @@ -3,147 +3,147 @@ package testdata import ( _ "fmt" - f_m_t "fmt" // ERROR "f_m_t is used under score. You should use mixedCap or MixedCap." + f_m_t "fmt" // ERROR "f_m_t contains underscore. You should use mixedCap or MixedCap." ) // global variable name with underscore. -var v_v = 0 // ERROR "v_v is used under score. You should use mixedCap or MixedCap." +var v_v = 0 // ERROR "v_v contains underscore. You should use mixedCap or MixedCap." // global constant name with underscore. -const c_c = 0 // ERROR "c_c is used under score. You should use mixedCap or MixedCap." +const c_c = 0 // ERROR "c_c contains underscore. You should use mixedCap or MixedCap." // struct name with underscore. -type S_a struct { // ERROR "S_a is used under score. You should use mixedCap or MixedCap." +type S_a struct { // ERROR "S_a contains underscore. You should use mixedCap or MixedCap." fi int } // non-exported struct field name with underscore. type Sa struct { - fi_a int // // ERROR "fi_a is used under score. You should use mixedCap or MixedCap." + fi_a int // // ERROR "fi_a contains underscore. You should use mixedCap or MixedCap." } // function as struct field, with parameter name with underscore. type Sb struct { - fib func(p_a int) // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + fib func(p_a int) // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." } // exported struct field with underscore. type Sc struct { - Fi_A int // ERROR "Fi_A is used under score. You should use mixedCap or MixedCap." + Fi_A int // ERROR "Fi_A contains underscore. You should use mixedCap or MixedCap." } // function as struct field, with return name with underscore. type Sd struct { - fib func(p int) (r_a int) // ERROR "r_a is used under score. You should use mixedCap or MixedCap." + fib func(p int) (r_a int) // ERROR "r_a contains underscore. You should use mixedCap or MixedCap." } // interface name with underscore. -type I_a interface { // ERROR "I_a is used under score. You should use mixedCap or MixedCap." +type I_a interface { // ERROR "I_a contains underscore. You should use mixedCap or MixedCap." fn(p int) } // interface with parameter name with underscore. type Ia interface { - fn(p_a int) // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + fn(p_a int) // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." } // interface with parameter name with underscore. type Ib interface { - Fn(p_a int) // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + Fn(p_a int) // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." } // function as struct field, with return name with underscore. type Ic interface { - Fn_a() // ERROR "Fn_a is used under score. You should use mixedCap or MixedCap." + Fn_a() // ERROR "Fn_a contains underscore. You should use mixedCap or MixedCap." } // interface with return name with underscore. type Id interface { - Fn() (r_a int) // ERROR "r_a is used under score. You should use mixedCap or MixedCap." + Fn() (r_a int) // ERROR "r_a contains underscore. You should use mixedCap or MixedCap." } // function name with underscore. -func f_a() {} // ERROR "f_a is used under score. You should use mixedCap or MixedCap." +func f_a() {} // ERROR "f_a contains underscore. You should use mixedCap or MixedCap." // function's parameter name with underscore. -func fb(p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." +func fb(p_a int) {} // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." // named return with underscore. -func fc() (r_b int) { // ERROR "r_b is used under score. You should use mixedCap or MixedCap." +func fc() (r_b int) { // ERROR "r_b contains underscore. You should use mixedCap or MixedCap." return 0 } // local variable (short declaration) with underscore. func fd(p int) int { - v_b := p * 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + v_b := p * 2 // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." - return v_b // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + return v_b // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." } // local constant with underscore. func fe(p int) int { - const v_b = 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + const v_b = 2 // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." - return v_b * p // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + return v_b * p // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." } // local variable with underscore. func ff(p int) int { - var v_b = 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + var v_b = 2 // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." - return v_b * p // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + return v_b * p // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." } // inner function, parameter name with underscore. func fg() { - fgl := func(p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." + fgl := func(p_a int) {} // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." fgl(1) } type Foo struct{} // method name with underscore. -func (f Foo) f_a() {} // ERROR "f_a is used under score. You should use mixedCap or MixedCap." +func (f Foo) f_a() {} // ERROR "f_a contains underscore. You should use mixedCap or MixedCap." // method's parameter name with underscore. -func (f Foo) fb(p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." +func (f Foo) fb(p_a int) {} // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." // named return with underscore. -func (f Foo) fc() (r_b int) { return 0 } // ERROR "r_b is used under score. You should use mixedCap or MixedCap." +func (f Foo) fc() (r_b int) { return 0 } // ERROR "r_b contains underscore. You should use mixedCap or MixedCap." // local variable (short declaration) with underscore. func (f Foo) fd(p int) int { - v_b := p * 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + v_b := p * 2 // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." - return v_b // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + return v_b // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." } // local constant with underscore. func (f Foo) fe(p int) int { - const v_b = 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + const v_b = 2 // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." - return v_b * p // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + return v_b * p // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." } // local variable with underscore. func (f Foo) ff(p int) int { - var v_b = 2 // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + var v_b = 2 // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." - return v_b * p // ERROR "v_b is used under score. You should use mixedCap or MixedCap." + return v_b * p // ERROR "v_b contains underscore. You should use mixedCap or MixedCap." } -func fna(a, p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." +func fna(a, p_a int) {} // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." -func fna1(a string, p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." +func fna1(a string, p_a int) {} // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." -func fnb(a, b, p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." +func fnb(a, b, p_a int) {} // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." -func fnb1(a, b string, p_a int) {} // ERROR "p_a is used under score. You should use mixedCap or MixedCap." +func fnb1(a, b string, p_a int) {} // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." func fnd( - p_a int, // ERROR "p_a is used under score. You should use mixedCap or MixedCap." - p_b int, // ERROR "p_b is used under score. You should use mixedCap or MixedCap." - p_c int, // ERROR "p_c is used under score. You should use mixedCap or MixedCap." + p_a int, // ERROR "p_a contains underscore. You should use mixedCap or MixedCap." + p_b int, // ERROR "p_b contains underscore. You should use mixedCap or MixedCap." + p_c int, // ERROR "p_c contains underscore. You should use mixedCap or MixedCap." ) { - f_m_t.Println("") // ERROR "f_m_t is used under score. You should use mixedCap or MixedCap." + f_m_t.Println("") // ERROR "f_m_t contains underscore. You should use mixedCap or MixedCap." } From 71a6c79c929889a907df66f37de08948835fb70b Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 28 Jun 2022 18:05:31 +0200 Subject: [PATCH 4/5] review: restore commit dropped during the rebase --- test/run_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run_test.go b/test/run_test.go index 07a31355c9ce..254f659787b9 100644 --- a/test/run_test.go +++ b/test/run_test.go @@ -95,7 +95,7 @@ func TestTestsAreLintedByDefault(t *testing.T) { } func TestCgoOk(t *testing.T) { - testshared.NewLintRunner(t).Run("--no-config", "--enable-all", getTestDataDir("cgo")).ExpectNoIssues() + testshared.NewLintRunner(t).Run("--no-config", "--enable-all", "-D", "nosnakecase", getTestDataDir("cgo")).ExpectNoIssues() } func TestCgoWithIssues(t *testing.T) { From 56eadea00647d74c625505c7db0c85ba7b902a46 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 28 Jun 2022 18:08:48 +0200 Subject: [PATCH 5/5] review: update Since --- pkg/lint/lintersdb/manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 4c8f74fb7c88..f85a0b16681e 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -632,7 +632,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithURL("https://github.com/firefart/nonamedreturns"), linter.NewConfig(golinters.NewNoSnakeCase()). - WithSince("v1.46.0"). + WithSince("v1.47.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/sivchari/nosnakecase"),