From 450301f44ad25c77459eec0f2ce3989eaf227140 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Sun, 6 Nov 2022 20:28:50 +0000 Subject: [PATCH 1/9] feat: add rowserr linter Add rowserr a linter which checks for missing sql Rows.Err() calls that supports generics. --- .golangci.reference.yml | 10 ++++++++++ go.mod | 1 + go.sum | 2 ++ pkg/config/linters_settings.go | 4 ++++ pkg/golinters/rowserr.go | 19 +++++++++++++++++++ pkg/lint/lintersdb/manager.go | 8 ++++++++ test/testdata/rowserr/rowserr.go | 17 +++++++++++++++++ 7 files changed, 61 insertions(+) create mode 100644 pkg/golinters/rowserr.go create mode 100644 test/testdata/rowserr/rowserr.go diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 4e9128df3306..020c35660f39 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -1636,6 +1636,14 @@ linters-settings: severity: warning disabled: false + rowserr: + # packages sets additional packages to check. + # The following know sql packages are always checked: + # - database/sql + # - github.com/jmoiron/sqlx + # Default: [] + packages: [] + rowserrcheck: # database/sql is always checked # Default: [] @@ -2039,6 +2047,7 @@ linters: - promlinter - reassign - revive + - rowserr - rowserrcheck - scopelint - sqlclosecheck @@ -2146,6 +2155,7 @@ linters: - promlinter - reassign - revive + - rowserr - rowserrcheck - scopelint - sqlclosecheck diff --git a/go.mod b/go.mod index 2b0b9e94034d..d24740933427 100644 --- a/go.mod +++ b/go.mod @@ -93,6 +93,7 @@ require ( github.com/spf13/viper v1.12.0 github.com/ssgreg/nlreturn/v2 v2.2.1 github.com/stbenjam/no-sprintf-host-port v0.1.1 + github.com/stevenh/go-rowserr v0.2.0 github.com/stretchr/testify v1.8.1 github.com/tdakkota/asciicheck v0.1.1 github.com/tetafro/godot v1.4.11 diff --git a/go.sum b/go.sum index 679db26e9dbf..6489738250c0 100644 --- a/go.sum +++ b/go.sum @@ -509,6 +509,8 @@ github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YE github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc= github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= +github.com/stevenh/go-rowserr v0.2.0 h1:E8c3GbJTBPX10OhfVzkWcHGNtyZQcS6Wtp+Rc02Z5kw= +github.com/stevenh/go-rowserr v0.2.0/go.mod h1:LuAr3Xi1Bk5P2O24jVtC16ifEGTmglx3md+9R2jFxl4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 412a6cc5d19b..ece2ebbed322 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -190,6 +190,7 @@ type LintersSettings struct { Promlinter PromlinterSettings Reassign ReassignSettings Revive ReviveSettings + RowsErr RowsErrSettings RowsErrCheck RowsErrCheckSettings Staticcheck StaticCheckSettings Structcheck StructCheckSettings @@ -600,6 +601,9 @@ type ReviveSettings struct { Severity string } } +type RowsErrSettings struct { + Packages []string +} type RowsErrCheckSettings struct { Packages []string diff --git a/pkg/golinters/rowserr.go b/pkg/golinters/rowserr.go new file mode 100644 index 000000000000..5450939d24a6 --- /dev/null +++ b/pkg/golinters/rowserr.go @@ -0,0 +1,19 @@ +package golinters + +import ( + "github.com/stevenh/go-rowserr/pkg/rowserr" + "golang.org/x/tools/go/analysis" + + "github.com/golangci/golangci-lint/pkg/config" + "github.com/golangci/golangci-lint/pkg/golinters/goanalysis" +) + +func NewRowsErr(settings *config.RowsErrSettings) *goanalysis.Linter { + a := rowserr.NewAnalyzer(settings.Packages...) + return goanalysis.NewLinter( + a.Name, + a.Doc, + []*analysis.Analyzer{a}, + nil, + ).WithLoadMode(goanalysis.LoadModeTypesInfo) +} diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 353ca88dcd7b..e3142d069cf2 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -158,6 +158,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { promlinterCfg *config.PromlinterSettings reassignCfg *config.ReassignSettings reviveCfg *config.ReviveSettings + rowserrCfg *config.RowsErrSettings rowserrcheckCfg *config.RowsErrCheckSettings staticcheckCfg *config.StaticCheckSettings structcheckCfg *config.StructCheckSettings @@ -234,6 +235,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { promlinterCfg = &m.cfg.LintersSettings.Promlinter reassignCfg = &m.cfg.LintersSettings.Reassign reviveCfg = &m.cfg.LintersSettings.Revive + rowserrCfg = &m.cfg.LintersSettings.RowsErr rowserrcheckCfg = &m.cfg.LintersSettings.RowsErrCheck staticcheckCfg = &m.cfg.LintersSettings.Staticcheck structcheckCfg = &m.cfg.LintersSettings.Structcheck @@ -707,6 +709,12 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { ConsiderSlow(). WithURL("https://github.com/mgechev/revive"), + linter.NewConfig(golinters.NewRowsErr(rowserrCfg)). + WithSince("v1.51.0"). + WithLoadForGoAnalysis(). + WithPresets(linter.PresetBugs, linter.PresetSQL). + WithURL("https://github.com/stevenh/go-rowserr"), + linter.NewConfig(golinters.NewRowsErrCheck(rowserrcheckCfg)). WithSince("v1.23.0"). WithLoadForGoAnalysis(). diff --git a/test/testdata/rowserr/rowserr.go b/test/testdata/rowserr/rowserr.go new file mode 100644 index 000000000000..42cc8416cd7b --- /dev/null +++ b/test/testdata/rowserr/rowserr.go @@ -0,0 +1,17 @@ +//golangcitest:args -Erowserr +package testdata + +import ( + "database/sql" +) + +func RowsErrNotChecked(db *sql.DB) { + rows, err := db.Query("select id from tb") // want "rows.Err\\(\\) must be checked" + if err != nil { + // Handle error. + } + + for rows.Next() { + // Handle row. + } +} From 4d19884a79c718c063fd9183370908df540651fb Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Mon, 7 Nov 2022 18:28:39 +0000 Subject: [PATCH 2/9] chore: refactor to uncalled Refactor to use uncalled which is a generic version rowserr that uses a configuration to enable rules based checks instead of hard-coded for database/sql Rows.Err() checks only. --- .golangci.reference.yml | 34 +++++++++++++------ go.mod | 2 +- go.sum | 4 +-- pkg/config/linters_settings.go | 8 ++--- pkg/golinters/{rowserr.go => uncalled.go} | 6 ++-- pkg/lint/lintersdb/manager.go | 16 ++++----- .../rowserr.go => uncalled/uncalled.go} | 0 7 files changed, 42 insertions(+), 28 deletions(-) rename pkg/golinters/{rowserr.go => uncalled.go} (65%) rename test/testdata/{rowserr/rowserr.go => uncalled/uncalled.go} (100%) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 020c35660f39..52fa4b8afb01 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -1636,14 +1636,6 @@ linters-settings: severity: warning disabled: false - rowserr: - # packages sets additional packages to check. - # The following know sql packages are always checked: - # - database/sql - # - github.com/jmoiron/sqlx - # Default: [] - packages: [] - rowserrcheck: # database/sql is always checked # Default: [] @@ -1754,6 +1746,28 @@ linters-settings: # Default: true begin: false + uncalled: + rules: + # Check for uncalled Rows.Err + - name: sql.Rows + disabled: false + severity: warning + packages: + - database/sql + - github.com/jmoiron/sqlx + call: + methods: [] + results: + - type: .Rows + pointer: true + - type: error + pointer: false + expect: + method: .Err + resultIndex: 0 + args: [] + + usestdlibvars: # Suggest the use of http.MethodXX. # Default: true @@ -2047,7 +2061,6 @@ linters: - promlinter - reassign - revive - - rowserr - rowserrcheck - scopelint - sqlclosecheck @@ -2061,6 +2074,7 @@ linters: - thelper - tparallel - typecheck + - uncalled - unconvert - unparam - unused @@ -2155,7 +2169,6 @@ linters: - promlinter - reassign - revive - - rowserr - rowserrcheck - scopelint - sqlclosecheck @@ -2169,6 +2182,7 @@ linters: - thelper - tparallel - typecheck + - uncalled - unconvert - unparam - unused diff --git a/go.mod b/go.mod index d24740933427..df32d329a5c3 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,7 @@ require ( github.com/spf13/viper v1.12.0 github.com/ssgreg/nlreturn/v2 v2.2.1 github.com/stbenjam/no-sprintf-host-port v0.1.1 - github.com/stevenh/go-rowserr v0.2.0 + github.com/stevenh/go-uncalled v0.3.0 github.com/stretchr/testify v1.8.1 github.com/tdakkota/asciicheck v0.1.1 github.com/tetafro/godot v1.4.11 diff --git a/go.sum b/go.sum index 6489738250c0..7bf2ef72bba9 100644 --- a/go.sum +++ b/go.sum @@ -509,8 +509,8 @@ github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YE github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc= github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= -github.com/stevenh/go-rowserr v0.2.0 h1:E8c3GbJTBPX10OhfVzkWcHGNtyZQcS6Wtp+Rc02Z5kw= -github.com/stevenh/go-rowserr v0.2.0/go.mod h1:LuAr3Xi1Bk5P2O24jVtC16ifEGTmglx3md+9R2jFxl4= +github.com/stevenh/go-uncalled v0.3.0 h1:jT6Li1MEj9noBdTFnVhu6iNj5v/JdrXXddL1Uy/jpwc= +github.com/stevenh/go-uncalled v0.3.0/go.mod h1:0UQfexEqWeq36xkgan9IDxKsYiNoE58vj4zNvSqBbFw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index ece2ebbed322..6211ed730886 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -4,6 +4,7 @@ import ( "runtime" "github.com/pkg/errors" + "github.com/stevenh/go-uncalled/pkg/uncalled" ) var defaultLintersSettings = LintersSettings{ @@ -190,7 +191,6 @@ type LintersSettings struct { Promlinter PromlinterSettings Reassign ReassignSettings Revive ReviveSettings - RowsErr RowsErrSettings RowsErrCheck RowsErrCheckSettings Staticcheck StaticCheckSettings Structcheck StructCheckSettings @@ -199,6 +199,7 @@ type LintersSettings struct { Tenv TenvSettings Testpackage TestpackageSettings Thelper ThelperSettings + Uncalled UncalledSettings Unparam UnparamSettings Unused StaticCheckSettings UseStdlibVars UseStdlibVarsSettings @@ -601,9 +602,8 @@ type ReviveSettings struct { Severity string } } -type RowsErrSettings struct { - Packages []string -} + +type UncalledSettings = uncalled.Config type RowsErrCheckSettings struct { Packages []string diff --git a/pkg/golinters/rowserr.go b/pkg/golinters/uncalled.go similarity index 65% rename from pkg/golinters/rowserr.go rename to pkg/golinters/uncalled.go index 5450939d24a6..bc0c9b50d8cc 100644 --- a/pkg/golinters/rowserr.go +++ b/pkg/golinters/uncalled.go @@ -1,15 +1,15 @@ package golinters import ( - "github.com/stevenh/go-rowserr/pkg/rowserr" + "github.com/stevenh/go-uncalled/pkg/uncalled" "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/pkg/config" "github.com/golangci/golangci-lint/pkg/golinters/goanalysis" ) -func NewRowsErr(settings *config.RowsErrSettings) *goanalysis.Linter { - a := rowserr.NewAnalyzer(settings.Packages...) +func NewUncalled(settings *config.UncalledSettings) *goanalysis.Linter { + a := uncalled.NewAnalyzer(settings) return goanalysis.NewLinter( a.Name, a.Doc, diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index e3142d069cf2..76af37473ead 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -158,7 +158,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { promlinterCfg *config.PromlinterSettings reassignCfg *config.ReassignSettings reviveCfg *config.ReviveSettings - rowserrCfg *config.RowsErrSettings rowserrcheckCfg *config.RowsErrCheckSettings staticcheckCfg *config.StaticCheckSettings structcheckCfg *config.StructCheckSettings @@ -167,6 +166,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { tenvCfg *config.TenvSettings testpackageCfg *config.TestpackageSettings thelperCfg *config.ThelperSettings + uncalledCfg *config.UncalledSettings unparamCfg *config.UnparamSettings unusedCfg *config.StaticCheckSettings usestdlibvars *config.UseStdlibVarsSettings @@ -235,7 +235,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { promlinterCfg = &m.cfg.LintersSettings.Promlinter reassignCfg = &m.cfg.LintersSettings.Reassign reviveCfg = &m.cfg.LintersSettings.Revive - rowserrCfg = &m.cfg.LintersSettings.RowsErr rowserrcheckCfg = &m.cfg.LintersSettings.RowsErrCheck staticcheckCfg = &m.cfg.LintersSettings.Staticcheck structcheckCfg = &m.cfg.LintersSettings.Structcheck @@ -244,6 +243,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { tenvCfg = &m.cfg.LintersSettings.Tenv testpackageCfg = &m.cfg.LintersSettings.Testpackage thelperCfg = &m.cfg.LintersSettings.Thelper + uncalledCfg = &m.cfg.LintersSettings.Uncalled unparamCfg = &m.cfg.LintersSettings.Unparam unusedCfg = &m.cfg.LintersSettings.Unused varcheckCfg = &m.cfg.LintersSettings.Varcheck @@ -709,12 +709,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { ConsiderSlow(). WithURL("https://github.com/mgechev/revive"), - linter.NewConfig(golinters.NewRowsErr(rowserrCfg)). - WithSince("v1.51.0"). - WithLoadForGoAnalysis(). - WithPresets(linter.PresetBugs, linter.PresetSQL). - WithURL("https://github.com/stevenh/go-rowserr"), - linter.NewConfig(golinters.NewRowsErrCheck(rowserrcheckCfg)). WithSince("v1.23.0"). WithLoadForGoAnalysis(). @@ -795,6 +789,12 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithPresets(linter.PresetBugs). WithURL(""), + linter.NewConfig(golinters.NewUncalled(uncalledCfg)). + WithSince("v1.51.0"). + WithLoadForGoAnalysis(). + WithPresets(linter.PresetBugs, linter.PresetSQL). + WithURL("https://github.com/stevenh/go-uncalled"), + linter.NewConfig(golinters.NewUnconvert()). WithSince("v1.0.0"). WithLoadForGoAnalysis(). diff --git a/test/testdata/rowserr/rowserr.go b/test/testdata/uncalled/uncalled.go similarity index 100% rename from test/testdata/rowserr/rowserr.go rename to test/testdata/uncalled/uncalled.go From 3d69f3ac7e1915e1133005b6bb9704d196bb61bf Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Mon, 7 Nov 2022 18:33:48 +0000 Subject: [PATCH 3/9] chore: update to uncalled v0.4.0 Update to uncalled v0.4.0 to align with golangci-lint config style. --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index df32d329a5c3..f92d70411c34 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,7 @@ require ( github.com/spf13/viper v1.12.0 github.com/ssgreg/nlreturn/v2 v2.2.1 github.com/stbenjam/no-sprintf-host-port v0.1.1 - github.com/stevenh/go-uncalled v0.3.0 + github.com/stevenh/go-uncalled v0.4.0 github.com/stretchr/testify v1.8.1 github.com/tdakkota/asciicheck v0.1.1 github.com/tetafro/godot v1.4.11 diff --git a/go.sum b/go.sum index 7bf2ef72bba9..d21148d40537 100644 --- a/go.sum +++ b/go.sum @@ -509,8 +509,8 @@ github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YE github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc= github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= -github.com/stevenh/go-uncalled v0.3.0 h1:jT6Li1MEj9noBdTFnVhu6iNj5v/JdrXXddL1Uy/jpwc= -github.com/stevenh/go-uncalled v0.3.0/go.mod h1:0UQfexEqWeq36xkgan9IDxKsYiNoE58vj4zNvSqBbFw= +github.com/stevenh/go-uncalled v0.4.0 h1:AhE32jsC+PzpXBe9+S4yvegslNL+611SeNkozA10Gao= +github.com/stevenh/go-uncalled v0.4.0/go.mod h1:0UQfexEqWeq36xkgan9IDxKsYiNoE58vj4zNvSqBbFw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= From 92f3c5f3371b567c40a331c4b9985416973d3fcc Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Tue, 8 Nov 2022 03:05:38 +0000 Subject: [PATCH 4/9] chore: update to uncalled v0.5.0 Update to uncalled v0.5.0 which adds net http response close checks. --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index f92d70411c34..fb5e7cb0ad89 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,7 @@ require ( github.com/spf13/viper v1.12.0 github.com/ssgreg/nlreturn/v2 v2.2.1 github.com/stbenjam/no-sprintf-host-port v0.1.1 - github.com/stevenh/go-uncalled v0.4.0 + github.com/stevenh/go-uncalled v0.5.0 github.com/stretchr/testify v1.8.1 github.com/tdakkota/asciicheck v0.1.1 github.com/tetafro/godot v1.4.11 diff --git a/go.sum b/go.sum index d21148d40537..302b985905a6 100644 --- a/go.sum +++ b/go.sum @@ -511,6 +511,8 @@ github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= github.com/stevenh/go-uncalled v0.4.0 h1:AhE32jsC+PzpXBe9+S4yvegslNL+611SeNkozA10Gao= github.com/stevenh/go-uncalled v0.4.0/go.mod h1:0UQfexEqWeq36xkgan9IDxKsYiNoE58vj4zNvSqBbFw= +github.com/stevenh/go-uncalled v0.5.0 h1:oHVQm8N0mdVBq55GH02wiht4fFM3gVFBc5N7BeZlJ1I= +github.com/stevenh/go-uncalled v0.5.0/go.mod h1:ejM8/UAWnsuI68d3Fpy/lLXwpdrvoweCSutU/Z4kNjc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= From 711bf0a8290a3d25da044be16b4451da897eb85c Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Tue, 8 Nov 2022 03:10:10 +0000 Subject: [PATCH 5/9] chore: run go mod tidy Run go mod tidy to clean up go.mod --- go.mod | 1 + go.sum | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index fb5e7cb0ad89..04e3eb711fc1 100644 --- a/go.mod +++ b/go.mod @@ -163,6 +163,7 @@ require ( github.com/quasilyte/gogrep v0.0.0-20220828223005-86e4605de09f // indirect github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect + github.com/rs/zerolog v1.28.0 // indirect github.com/sivchari/nosnakecase v1.7.0 github.com/spf13/afero v1.8.2 // indirect github.com/spf13/cast v1.5.0 // indirect diff --git a/go.sum b/go.sum index 302b985905a6..13bc637bdf87 100644 --- a/go.sum +++ b/go.sum @@ -102,6 +102,7 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cristalhq/acmd v0.8.1/go.mod h1:LG5oa43pE/BbxtfMoImHCQN++0Su7dzipdgBjMCBVDQ= @@ -172,6 +173,7 @@ github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b h1:khEcpUM4yFcxg4 github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -354,6 +356,7 @@ github.com/matoous/godox v0.0.0-20210227103229-6504466cf951/go.mod h1:1BELzlh859 github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= @@ -459,6 +462,9 @@ github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4l github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= +github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryancurrah/gomodguard v1.2.4 h1:CpMSDKan0LtNGGhPrvupAoLeObRFjND8/tU1rEOtBp4= github.com/ryancurrah/gomodguard v1.2.4/go.mod h1:+Kem4VjWwvFpUJRJSwa16s1tBJe+vbv02+naTow2f6M= @@ -509,8 +515,6 @@ github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YE github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc= github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= -github.com/stevenh/go-uncalled v0.4.0 h1:AhE32jsC+PzpXBe9+S4yvegslNL+611SeNkozA10Gao= -github.com/stevenh/go-uncalled v0.4.0/go.mod h1:0UQfexEqWeq36xkgan9IDxKsYiNoE58vj4zNvSqBbFw= github.com/stevenh/go-uncalled v0.5.0 h1:oHVQm8N0mdVBq55GH02wiht4fFM3gVFBc5N7BeZlJ1I= github.com/stevenh/go-uncalled v0.5.0/go.mod h1:ejM8/UAWnsuI68d3Fpy/lLXwpdrvoweCSutU/Z4kNjc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -761,6 +765,7 @@ golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From 251249750e6a6e581e95460fc0e71c7f49767538 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Tue, 8 Nov 2022 15:56:31 +0000 Subject: [PATCH 6/9] feat: update to uncalled v0.7.1 Update to uncalled v0.7.1 which adds more checkers, adds the ability to handle more called types including direct calls in defers. This adds the following new rules: - http Response.Body.Close() - context context.CancelFunc() --- .golangci.reference.yml | 62 +++++++++++++++++++++++++++++---------- go.mod | 2 +- go.sum | 4 +++ pkg/golinters/uncalled.go | 2 +- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 52fa4b8afb01..7b92ec158ea0 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -1747,25 +1747,57 @@ linters-settings: begin: false uncalled: + default-category: uncalled rules: - # Check for uncalled Rows.Err - - name: sql.Rows - disabled: false - severity: warning + # Checks for missing sql Rows.Err() calls. + - name: sql-rows-err + # Default: false + disabled: true + category: sql packages: - database/sql - github.com/jmoiron/sqlx - call: - methods: [] - results: - - type: .Rows - pointer: true - - type: error - pointer: false - expect: - method: .Err - resultIndex: 0 - args: [] + methods: [] + results: + - type: .Rows + pointer: true + expect: + call: .Err + args: [] + - type: error + pointer: false + # Checks for missing http Reponse.Body.Close() calls. + - name: http-response-body-close + # Default: false + disabled: true + category: http + packages: + - net/http + methods: [] + results: + - type: .Response + pointer: true + expect: + call: .Body.Close + args: [] + - type: error + pointer: false + # Checks for missing context CancelFunc() calls. + - name: context-cancel + # Default: false + disabled: true + category: context + packages: + - context + methods: [] + results: + - type: .Context + pointer: false + - type: .CancelFunc + pointer: false + expect: + call: + args: [] usestdlibvars: diff --git a/go.mod b/go.mod index 04e3eb711fc1..45a2fb79ed50 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,7 @@ require ( github.com/spf13/viper v1.12.0 github.com/ssgreg/nlreturn/v2 v2.2.1 github.com/stbenjam/no-sprintf-host-port v0.1.1 - github.com/stevenh/go-uncalled v0.5.0 + github.com/stevenh/go-uncalled v0.7.1 github.com/stretchr/testify v1.8.1 github.com/tdakkota/asciicheck v0.1.1 github.com/tetafro/godot v1.4.11 diff --git a/go.sum b/go.sum index 13bc637bdf87..6568b40179be 100644 --- a/go.sum +++ b/go.sum @@ -517,6 +517,10 @@ github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= github.com/stevenh/go-uncalled v0.5.0 h1:oHVQm8N0mdVBq55GH02wiht4fFM3gVFBc5N7BeZlJ1I= github.com/stevenh/go-uncalled v0.5.0/go.mod h1:ejM8/UAWnsuI68d3Fpy/lLXwpdrvoweCSutU/Z4kNjc= +github.com/stevenh/go-uncalled v0.7.0 h1:0w7kXgJoLH40y0NLTJARXywi0ZKTMITCes8vsunvVp8= +github.com/stevenh/go-uncalled v0.7.0/go.mod h1:ejM8/UAWnsuI68d3Fpy/lLXwpdrvoweCSutU/Z4kNjc= +github.com/stevenh/go-uncalled v0.7.1 h1:6C3aV7txvAW9Ip0kN7l1jM8Pb315hhlKzYObBdt3xJg= +github.com/stevenh/go-uncalled v0.7.1/go.mod h1:ejM8/UAWnsuI68d3Fpy/lLXwpdrvoweCSutU/Z4kNjc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= diff --git a/pkg/golinters/uncalled.go b/pkg/golinters/uncalled.go index bc0c9b50d8cc..aa004575fc12 100644 --- a/pkg/golinters/uncalled.go +++ b/pkg/golinters/uncalled.go @@ -9,7 +9,7 @@ import ( ) func NewUncalled(settings *config.UncalledSettings) *goanalysis.Linter { - a := uncalled.NewAnalyzer(settings) + a := uncalled.NewAnalyzer(uncalled.ConfigOpt(settings)) return goanalysis.NewLinter( a.Name, a.Doc, From a649a25b92a3b709e2ffde2360cc674460ed7a24 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Tue, 8 Nov 2022 18:07:42 +0000 Subject: [PATCH 7/9] core: add default config Add default config, correct want and fix linter name. --- go.mod | 2 +- go.sum | 8 ++------ pkg/config/linters_settings.go | 1 + test/linters_test.go | 1 + test/testdata/uncalled/uncalled.go | 4 ++-- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 45a2fb79ed50..a5b322ca979e 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,7 @@ require ( github.com/spf13/viper v1.12.0 github.com/ssgreg/nlreturn/v2 v2.2.1 github.com/stbenjam/no-sprintf-host-port v0.1.1 - github.com/stevenh/go-uncalled v0.7.1 + github.com/stevenh/go-uncalled v0.7.3 github.com/stretchr/testify v1.8.1 github.com/tdakkota/asciicheck v0.1.1 github.com/tetafro/godot v1.4.11 diff --git a/go.sum b/go.sum index 6568b40179be..3e1e79c1751c 100644 --- a/go.sum +++ b/go.sum @@ -515,12 +515,8 @@ github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YE github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc= github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= -github.com/stevenh/go-uncalled v0.5.0 h1:oHVQm8N0mdVBq55GH02wiht4fFM3gVFBc5N7BeZlJ1I= -github.com/stevenh/go-uncalled v0.5.0/go.mod h1:ejM8/UAWnsuI68d3Fpy/lLXwpdrvoweCSutU/Z4kNjc= -github.com/stevenh/go-uncalled v0.7.0 h1:0w7kXgJoLH40y0NLTJARXywi0ZKTMITCes8vsunvVp8= -github.com/stevenh/go-uncalled v0.7.0/go.mod h1:ejM8/UAWnsuI68d3Fpy/lLXwpdrvoweCSutU/Z4kNjc= -github.com/stevenh/go-uncalled v0.7.1 h1:6C3aV7txvAW9Ip0kN7l1jM8Pb315hhlKzYObBdt3xJg= -github.com/stevenh/go-uncalled v0.7.1/go.mod h1:ejM8/UAWnsuI68d3Fpy/lLXwpdrvoweCSutU/Z4kNjc= +github.com/stevenh/go-uncalled v0.7.3 h1:nME2E+qUieDR2dC8gFJdo9BeV153rsu0NVwCBr42qKg= +github.com/stevenh/go-uncalled v0.7.3/go.mod h1:ejM8/UAWnsuI68d3Fpy/lLXwpdrvoweCSutU/Z4kNjc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 6211ed730886..30f2ff36ee99 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -109,6 +109,7 @@ var defaultLintersSettings = LintersSettings{ SkipRegexp: `(export|internal)_test\.go`, AllowPackages: []string{"main"}, }, + Uncalled: uncalled.DefaultConfig(), Unparam: UnparamSettings{ Algo: "cha", }, diff --git a/test/linters_test.go b/test/linters_test.go index 159e76c8bb56..2e54ea95a9e7 100644 --- a/test/linters_test.go +++ b/test/linters_test.go @@ -30,6 +30,7 @@ func TestTypecheck(t *testing.T) { func TestSourcesFromTestdataSubDir(t *testing.T) { subDirs := []string{ "loggercheck", + "uncalled", } for _, dir := range subDirs { diff --git a/test/testdata/uncalled/uncalled.go b/test/testdata/uncalled/uncalled.go index 42cc8416cd7b..e71f7c180316 100644 --- a/test/testdata/uncalled/uncalled.go +++ b/test/testdata/uncalled/uncalled.go @@ -1,4 +1,4 @@ -//golangcitest:args -Erowserr +//golangcitest:args -Euncalled package testdata import ( @@ -6,7 +6,7 @@ import ( ) func RowsErrNotChecked(db *sql.DB) { - rows, err := db.Query("select id from tb") // want "rows.Err\\(\\) must be checked" + rows, err := db.Query("select id from tb") // want "rows.Err\\(\\) must be called" if err != nil { // Handle error. } From 5a26360429a551b3522e8c336b2e6d9b62bae8b7 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Fri, 11 Nov 2022 15:31:50 +0000 Subject: [PATCH 8/9] feat: update to v0.8.0 merge config Update to v0.8.0 which adds merge config support. This improves compatibility with golangci-lint by allowing the internal rules to be applied and overridden with minimal configuration. --- .golangci.reference.yml | 51 ++++++++++------------------------ go.mod | 2 +- go.sum | 4 +-- pkg/config/linters_settings.go | 11 ++++++-- 4 files changed, 25 insertions(+), 43 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 7b92ec158ea0..9186cc00ebd7 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -1747,45 +1747,22 @@ linters-settings: begin: false uncalled: - default-category: uncalled + # Disables all rules. + # Default: false + disabled-all: true + # Disables the given rules. + # Default: [] + disabled: + - context-cancel + # Enables specific rules, in combination with disable all. + # Default: [] + enabled: + - sql-rows-err + # Add or override default rules. + # Default: [] rules: - # Checks for missing sql Rows.Err() calls. - - name: sql-rows-err - # Default: false - disabled: true - category: sql - packages: - - database/sql - - github.com/jmoiron/sqlx - methods: [] - results: - - type: .Rows - pointer: true - expect: - call: .Err - args: [] - - type: error - pointer: false - # Checks for missing http Reponse.Body.Close() calls. - - name: http-response-body-close - # Default: false - disabled: true - category: http - packages: - - net/http - methods: [] - results: - - type: .Response - pointer: true - expect: - call: .Body.Close - args: [] - - type: error - pointer: false - # Checks for missing context CancelFunc() calls. + # Check for missing context CancelFunc() calls. - name: context-cancel - # Default: false - disabled: true category: context packages: - context diff --git a/go.mod b/go.mod index a5b322ca979e..5a2e147058d3 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,7 @@ require ( github.com/spf13/viper v1.12.0 github.com/ssgreg/nlreturn/v2 v2.2.1 github.com/stbenjam/no-sprintf-host-port v0.1.1 - github.com/stevenh/go-uncalled v0.7.3 + github.com/stevenh/go-uncalled v0.8.0 github.com/stretchr/testify v1.8.1 github.com/tdakkota/asciicheck v0.1.1 github.com/tetafro/godot v1.4.11 diff --git a/go.sum b/go.sum index 3e1e79c1751c..03625e2ba4da 100644 --- a/go.sum +++ b/go.sum @@ -515,8 +515,8 @@ github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YE github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc= github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= -github.com/stevenh/go-uncalled v0.7.3 h1:nME2E+qUieDR2dC8gFJdo9BeV153rsu0NVwCBr42qKg= -github.com/stevenh/go-uncalled v0.7.3/go.mod h1:ejM8/UAWnsuI68d3Fpy/lLXwpdrvoweCSutU/Z4kNjc= +github.com/stevenh/go-uncalled v0.8.0 h1:avctwO9QTaMulHHfwuaYN9N21yrlgyGnSYPLmF1wXp8= +github.com/stevenh/go-uncalled v0.8.0/go.mod h1:susI8UKFPgJnpDU0zM7eLuI1x65Ha+YZGkg4h1Vpd0M= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 30f2ff36ee99..bc5fcaf358cb 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -109,7 +109,12 @@ var defaultLintersSettings = LintersSettings{ SkipRegexp: `(export|internal)_test\.go`, AllowPackages: []string{"main"}, }, - Uncalled: uncalled.DefaultConfig(), + Uncalled: UncalledSettings{ + DisableAll: false, + Enabled: nil, + Disabled: nil, + Rules: nil, + }, Unparam: UnparamSettings{ Algo: "cha", }, @@ -604,8 +609,6 @@ type ReviveSettings struct { } } -type UncalledSettings = uncalled.Config - type RowsErrCheckSettings struct { Packages []string } @@ -672,6 +675,8 @@ type UseStdlibVarsSettings struct { SyslogPriority bool `mapstructure:"syslog-priority"` } +type UncalledSettings = uncalled.Config + type UnparamSettings struct { CheckExported bool `mapstructure:"check-exported"` Algo string From 602314d6d9ab8b0438d75da6cf396070e1b030fb Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Sat, 17 Dec 2022 18:32:47 +0000 Subject: [PATCH 9/9] chore: update to uncalled v0.8.1 Update uncalled to v0.8.1 which addresses a config data race. --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 5a2e147058d3..138f7af6bc89 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,7 @@ require ( github.com/spf13/viper v1.12.0 github.com/ssgreg/nlreturn/v2 v2.2.1 github.com/stbenjam/no-sprintf-host-port v0.1.1 - github.com/stevenh/go-uncalled v0.8.0 + github.com/stevenh/go-uncalled v0.8.1 github.com/stretchr/testify v1.8.1 github.com/tdakkota/asciicheck v0.1.1 github.com/tetafro/godot v1.4.11 diff --git a/go.sum b/go.sum index 03625e2ba4da..f7e670977dfe 100644 --- a/go.sum +++ b/go.sum @@ -517,6 +517,8 @@ github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= github.com/stevenh/go-uncalled v0.8.0 h1:avctwO9QTaMulHHfwuaYN9N21yrlgyGnSYPLmF1wXp8= github.com/stevenh/go-uncalled v0.8.0/go.mod h1:susI8UKFPgJnpDU0zM7eLuI1x65Ha+YZGkg4h1Vpd0M= +github.com/stevenh/go-uncalled v0.8.1 h1:eSLB7XXbCweqfJn8WkwDaOnZR1f5Als1QDyIJlQZNsI= +github.com/stevenh/go-uncalled v0.8.1/go.mod h1:susI8UKFPgJnpDU0zM7eLuI1x65Ha+YZGkg4h1Vpd0M= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=