File tree 5 files changed +46
-0
lines changed
5 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ require (
73
73
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c
74
74
github.com/shirou/gopsutil/v3 v3.21.10
75
75
github.com/sirupsen/logrus v1.8.1
76
+ github.com/sivchari/containedctx v1.0.0
76
77
github.com/sivchari/tenv v1.4.7
77
78
github.com/sonatard/noctx v0.0.1
78
79
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 {
555
555
WithPresets (linter .PresetBugs ).
556
556
WithLoadForGoAnalysis ().
557
557
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" ),
558
563
559
564
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives
560
565
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