diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-11-11 11:41:38 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-11-11 11:10:48 +0000 |
| commit | 27e76fae2ee2d84dc7db63af1d9ed7358ba35b7a (patch) | |
| tree | ed19c0e35e272b3c4cc5a2f2c595e035b2428337 /vendor/github.com/sonatard | |
| parent | 621e84e063b0e15b23e17780338627c509e1b9e8 (diff) | |
vendor: update
Diffstat (limited to 'vendor/github.com/sonatard')
| -rw-r--r-- | vendor/github.com/sonatard/noctx/.gitignore | 1 | ||||
| -rw-r--r-- | vendor/github.com/sonatard/noctx/.golangci.yml | 52 | ||||
| -rw-r--r-- | vendor/github.com/sonatard/noctx/.goreleaser.yml | 37 | ||||
| -rw-r--r-- | vendor/github.com/sonatard/noctx/Makefile | 6 | ||||
| -rw-r--r-- | vendor/github.com/sonatard/noctx/README.md | 7 | ||||
| -rw-r--r-- | vendor/github.com/sonatard/noctx/ngfunc/main.go | 1 | ||||
| -rw-r--r-- | vendor/github.com/sonatard/noctx/ngfunc/report.go | 2 | ||||
| -rw-r--r-- | vendor/github.com/sonatard/noctx/ngfunc/types.go | 4 | ||||
| -rw-r--r-- | vendor/github.com/sonatard/noctx/noctx.go | 1 | ||||
| -rw-r--r-- | vendor/github.com/sonatard/noctx/reqwithoutctx/report.go | 2 | ||||
| -rw-r--r-- | vendor/github.com/sonatard/noctx/reqwithoutctx/ssa.go | 3 |
11 files changed, 92 insertions, 24 deletions
diff --git a/vendor/github.com/sonatard/noctx/.gitignore b/vendor/github.com/sonatard/noctx/.gitignore index 2d830686d..8dfb40ff1 100644 --- a/vendor/github.com/sonatard/noctx/.gitignore +++ b/vendor/github.com/sonatard/noctx/.gitignore @@ -1 +1,2 @@ coverage.out +/noctx diff --git a/vendor/github.com/sonatard/noctx/.golangci.yml b/vendor/github.com/sonatard/noctx/.golangci.yml index 55ebeebdb..726cb7c89 100644 --- a/vendor/github.com/sonatard/noctx/.golangci.yml +++ b/vendor/github.com/sonatard/noctx/.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/vendor/github.com/sonatard/noctx/.goreleaser.yml b/vendor/github.com/sonatard/noctx/.goreleaser.yml new file mode 100644 index 000000000..9000b50a1 --- /dev/null +++ b/vendor/github.com/sonatard/noctx/.goreleaser.yml @@ -0,0 +1,37 @@ +version: 2 +project_name: noctx + +builds: + - binary: noctx + + main: ./cmd/noctx/main.go + env: + - CGO_ENABLED=0 + flags: + - -trimpath + goos: + - windows + - darwin + - linux + goarch: + - amd64 + - 386 + - arm + - arm64 + goarm: + - 7 + - 6 + - 5 + ignore: + - goos: darwin + goarch: 386 + +archives: + - id: noctx + name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}' + format: tar.gz + format_overrides: + - goos: windows + format: zip + files: + - LICENSE diff --git a/vendor/github.com/sonatard/noctx/Makefile b/vendor/github.com/sonatard/noctx/Makefile index 1a27f6b59..585a9d7e2 100644 --- a/vendor/github.com/sonatard/noctx/Makefile +++ b/vendor/github.com/sonatard/noctx/Makefile @@ -1,6 +1,6 @@ -.PHONY: all imports test lint +.PHONY: all imports test lint build -all: imports test lint +all: imports test lint build imports: goimports -w ./ @@ -14,3 +14,5 @@ test_coverage: lint: golangci-lint run ./... +build: + go build -ldflags "-s -w" -trimpath ./cmd/noctx/ diff --git a/vendor/github.com/sonatard/noctx/README.md b/vendor/github.com/sonatard/noctx/README.md index b3793fc96..00d0024c5 100644 --- a/vendor/github.com/sonatard/noctx/README.md +++ b/vendor/github.com/sonatard/noctx/README.md @@ -52,10 +52,11 @@ linters: $ golangci-lint run # Only noctx execute -golangci-lint run --disable-all -E noctx +golangci-lint run --enable-only noctx ``` ## Detection rules + - Executing following functions - `net/http.Get` - `net/http.Head` @@ -68,6 +69,7 @@ golangci-lint run --disable-all -E noctx - `http.Request` returned by `http.NewRequest` function and passes it to other function. ## How to fix + - Send http request using `(*http.Client).Do(*http.Request)` method. - In Go 1.13 and later, use `http.NewRequestWithContext` function instead of using `http.NewRequest` function. - In Go 1.12 and earlier, call `(http.Request).WithContext(ctx)` after `http.NewRequest`. @@ -107,7 +109,7 @@ func SendWithContext(ctx context.Context, body io.Reader) error { // Change NewRequest to NewRequestWithContext and pass context it req, err := http.NewRequestWithContext(ctx, http.MethodPost, "http://example.com", body) if err != nil { - return nil + return err } _, err = http.DefaultClient.Do(req) if err != nil { @@ -168,6 +170,7 @@ func main() { ``` ## Reference + - [net/http - NewRequest](https://golang.org/pkg/net/http/#NewRequest) - [net/http - NewRequestWithContext](https://golang.org/pkg/net/http/#NewRequestWithContext) - [net/http - Request.WithContext](https://golang.org/pkg/net/http/#Request.WithContext) diff --git a/vendor/github.com/sonatard/noctx/ngfunc/main.go b/vendor/github.com/sonatard/noctx/ngfunc/main.go index 46306218d..8d8d97d93 100644 --- a/vendor/github.com/sonatard/noctx/ngfunc/main.go +++ b/vendor/github.com/sonatard/noctx/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/vendor/github.com/sonatard/noctx/ngfunc/report.go b/vendor/github.com/sonatard/noctx/ngfunc/report.go index e50051798..735aa1cf9 100644 --- a/vendor/github.com/sonatard/noctx/ngfunc/report.go +++ b/vendor/github.com/sonatard/noctx/ngfunc/report.go @@ -24,6 +24,6 @@ func (n *Report) Message() string { func report(pass *analysis.Pass, reports []*Report) { for _, report := range reports { - pass.Reportf(report.Pos(), report.Message()) + pass.Reportf(report.Pos(), "%s", report.Message()) } } diff --git a/vendor/github.com/sonatard/noctx/ngfunc/types.go b/vendor/github.com/sonatard/noctx/ngfunc/types.go index f1877386c..8f81c6aa2 100644 --- a/vendor/github.com/sonatard/noctx/ngfunc/types.go +++ b/vendor/github.com/sonatard/noctx/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/vendor/github.com/sonatard/noctx/noctx.go b/vendor/github.com/sonatard/noctx/noctx.go index 89e0446ec..fbffb66e7 100644 --- a/vendor/github.com/sonatard/noctx/noctx.go +++ b/vendor/github.com/sonatard/noctx/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/vendor/github.com/sonatard/noctx/reqwithoutctx/report.go b/vendor/github.com/sonatard/noctx/reqwithoutctx/report.go index 1c94e3148..3bf2ea01f 100644 --- a/vendor/github.com/sonatard/noctx/reqwithoutctx/report.go +++ b/vendor/github.com/sonatard/noctx/reqwithoutctx/report.go @@ -21,6 +21,6 @@ func (n *Report) Message() string { func report(pass *analysis.Pass, reports []*Report) { for _, report := range reports { - pass.Reportf(report.Pos(), report.Message()) + pass.Reportf(report.Pos(), "%s", report.Message()) } } diff --git a/vendor/github.com/sonatard/noctx/reqwithoutctx/ssa.go b/vendor/github.com/sonatard/noctx/reqwithoutctx/ssa.go index d7e0f5084..62707c6b5 100644 --- a/vendor/github.com/sonatard/noctx/reqwithoutctx/ssa.go +++ b/vendor/github.com/sonatard/noctx/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" @@ -97,7 +96,7 @@ func (a *Analyzer) usedReqByCall(call *ssa.Call) []*ssa.Extract { exts := make([]*ssa.Extract, 0, len(args)) // skip net/http.Request method call - if call.Common().Signature().Recv() != nil && types.Identical(call.Value().Type(), a.requestType) { + if recv := call.Common().Signature().Recv(); recv != nil && types.Identical(recv.Type(), a.requestType) { return exts } |
