File tree Expand file tree Collapse file tree 5 files changed +46
-0
lines changed
Expand file tree Collapse file tree 5 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ require (
7373 github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c
7474 github.com/shirou/gopsutil/v3 v3.21.10
7575 github.com/sirupsen/logrus v1.8.1
76+ github.com/sivchari/containedctx v1.0.0
7677 github.com/sivchari/tenv v1.4.7
7778 github.com/sonatard/noctx v0.0.1
7879 github.com/sourcegraph/go-diff v0.6.1
Original file line number Diff line number Diff line change 1+ package golinters
2+
3+ import (
4+ "github.com/sivchari/containedctx"
5+ "golang.org/x/tools/go/analysis"
6+
7+ "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
8+ )
9+
10+ func NewContainedCtx () * goanalysis.Linter {
11+ a := containedctx .Analyzer
12+
13+ analyzers := []* analysis.Analyzer {
14+ a ,
15+ }
16+
17+ return goanalysis .NewLinter (
18+ a .Name ,
19+ a .Doc ,
20+ analyzers ,
21+ nil ,
22+ ).WithLoadMode (goanalysis .LoadModeSyntax )
23+ }
Original file line number Diff line number Diff line change @@ -555,6 +555,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
555555 WithPresets (linter .PresetBugs ).
556556 WithLoadForGoAnalysis ().
557557 WithURL ("https://github.com/breml/errchkjson" ),
558+ linter .NewConfig (golinters .NewContainedCtx ()).
559+ WithSince ("1.44.0" ).
560+ WithPresets (linter .PresetStyle ).
561+ WithLoadForGoAnalysis ().
562+ WithURL ("https://github.com/sivchari/containedctx" ),
558563
559564 // nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives
560565 linter .NewConfig (golinters .NewNoLintLint ()).
Original file line number Diff line number Diff line change 1+ // args: -Econtainedctx
2+ package testdata
3+
4+ import "context"
5+
6+ type ok struct {
7+ i int
8+ s string
9+ }
10+
11+ type ng struct {
12+ ctx context.Context // ERROR "found a struct that contains a context.Context field"
13+ }
14+
15+ type empty struct {}
You can’t perform that action at this time.
0 commit comments