From 5b0c645e24572ce3734a32f9cb9fb29133fc250d Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 15 Sep 2024 14:58:12 +0200 Subject: [PATCH] fix: linting --- .golangci.yml | 52 ++++++++++++++++++++++++++++++++------------ ngfunc/main.go | 1 + ngfunc/types.go | 4 ++-- noctx.go | 1 + reqwithoutctx/ssa.go | 1 - 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 55ebeeb..726cb7c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,14 +1,38 @@ -run: - linters-settings: - govet: - enable-all: true - linters: - enable-all: true - disable: - - gochecknoglobals - - gomnd - - gocognit - - nestif - - nilnil - - paralleltest - - varnamelen \ No newline at end of file +linters: + enable-all: true + disable: + - execinquery # deprecated + - exportloopref # deprecated + - gomnd # deprecated + - gochecknoglobals + - exhaustruct + - mnd + - gocognit + - nestif + - nilnil + - paralleltest + - varnamelen + +linters-settings: + govet: + enable-all: true + perfsprint: + err-error: true + errorf: true + sprintf1: true + strconcat: false + depguard: + rules: + main: + deny: + - pkg: "github.com/instana/testify" + desc: not allowed + - pkg: "github.com/pkg/errors" + desc: Should be replaced by standard lib errors package + +output: + show-stats: true + sort-results: true + sort-order: + - linter + - file diff --git a/ngfunc/main.go b/ngfunc/main.go index 4630621..8d8d97d 100644 --- a/ngfunc/main.go +++ b/ngfunc/main.go @@ -39,6 +39,7 @@ func ngCalledFuncs(pass *analysis.Pass, ngFuncs []*types.Func) []*Report { if !ok { panic(fmt.Sprintf("%T is not *buildssa.SSA", pass.ResultOf[buildssa.Analyzer])) } + for _, sf := range ssa.SrcFuncs { for _, b := range sf.Blocks { for _, instr := range b.Instrs { diff --git a/ngfunc/types.go b/ngfunc/types.go index f187738..8f81c6a 100644 --- a/ngfunc/types.go +++ b/ngfunc/types.go @@ -1,7 +1,7 @@ package ngfunc import ( - "fmt" + "errors" "go/types" "strings" @@ -9,7 +9,7 @@ import ( "golang.org/x/tools/go/analysis" ) -var errNotFound = fmt.Errorf("function not found") +var errNotFound = errors.New("function not found") func typeFuncs(pass *analysis.Pass, funcs []string) []*types.Func { fs := make([]*types.Func, 0, len(funcs)) diff --git a/noctx.go b/noctx.go index 89e0446..fbffb66 100644 --- a/noctx.go +++ b/noctx.go @@ -2,6 +2,7 @@ package noctx import ( "fmt" + "github.com/sonatard/noctx/ngfunc" "github.com/sonatard/noctx/reqwithoutctx" "golang.org/x/tools/go/analysis" diff --git a/reqwithoutctx/ssa.go b/reqwithoutctx/ssa.go index 2a52e89..62707c6 100644 --- a/reqwithoutctx/ssa.go +++ b/reqwithoutctx/ssa.go @@ -5,7 +5,6 @@ import ( "go/types" "github.com/gostaticanalysis/analysisutil" - "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/buildssa" "golang.org/x/tools/go/ssa"