Skip to content

Commit 396d553

Browse files
build(deps): bump go.augendre.info/fatcontext from 0.9.0 to 0.10.0 (#6653)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
1 parent e60c937 commit 396d553

11 files changed

Lines changed: 115 additions & 5 deletions

.golangci.next.reference.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,12 @@ linters:
624624
# May generate false positives.
625625
# Default: false
626626
check-struct-pointers: true
627+
# Disable detection of fat contexts in loops.
628+
# Default: true
629+
check-loops: false
630+
# Disable detection of fat contexts in function literals.
631+
# Default: true
632+
check-function-literals: false
627633

628634
forbidigo:
629635
# Forbid the following identifiers (list of regexp).

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ require (
149149
go-simpler.org/musttag v0.14.0
150150
go-simpler.org/sloglint v0.12.0
151151
go.augendre.info/arangolint v0.4.0
152-
go.augendre.info/fatcontext v0.9.0
152+
go.augendre.info/fatcontext v0.10.0
153153
go.yaml.in/yaml/v3 v3.0.4
154154
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b
155155
golang.org/x/mod v0.37.0

go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.next.jsonschema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,16 @@
15081508
"description": "Check for potential fat contexts in struct pointers.",
15091509
"type": "boolean",
15101510
"default": false
1511+
},
1512+
"check-loops": {
1513+
"description": "Disable detection of fat contexts in function literals.",
1514+
"type": "boolean",
1515+
"default": true
1516+
},
1517+
"check-function-literals": {
1518+
"description": "Disable detection of fat contexts in function literals.",
1519+
"type": "boolean",
1520+
"default": true
15111521
}
15121522
}
15131523
},

pkg/config/linters_settings.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ var defaultLintersSettings = LintersSettings{
4141
ExplicitExhaustiveMap: false,
4242
ExplicitExhaustiveSwitch: false,
4343
},
44+
Fatcontext: FatcontextSettings{
45+
CheckStructPointers: false,
46+
CheckLoops: true,
47+
CheckFunctionLiterals: true,
48+
},
4449
Forbidigo: ForbidigoSettings{
4550
ExcludeGodocExamples: true,
4651
},
@@ -487,7 +492,9 @@ type ExhaustructV5Settings struct {
487492
}
488493

489494
type FatcontextSettings struct {
490-
CheckStructPointers bool `mapstructure:"check-struct-pointers"`
495+
CheckStructPointers bool `mapstructure:"check-struct-pointers"`
496+
CheckLoops bool `mapstructure:"check-loops"`
497+
CheckFunctionLiterals bool `mapstructure:"check-function-literals"`
491498
}
492499

493500
type ForbidigoSettings struct {

pkg/golinters/fatcontext/fatcontext.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ func New(settings *config.FatcontextSettings) *goanalysis.Linter {
1212

1313
if settings != nil {
1414
cfg = map[string]any{
15-
analyzer.FlagCheckStructPointers: settings.CheckStructPointers,
15+
analyzer.FlagCheckStructPointers: settings.CheckStructPointers,
16+
analyzer.FlagCheckLoops: settings.CheckLoops,
17+
analyzer.FlagCheckFunctionLiterals: settings.CheckFunctionLiterals,
1618
}
1719
}
1820

pkg/golinters/fatcontext/testdata/fatcontext.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,24 @@ func inStructs(ctx context.Context) {
7272
rp[0].Ctx = context.WithValue(rp[0].Ctx, "other", "val")
7373
}
7474
}
75+
76+
// Loop detection stays enabled: this MUST be reported.
77+
func _() {
78+
ctx := context.Background()
79+
80+
for i := 0; i < 10; i++ {
81+
ctx = context.WithValue(ctx, "key", i) // want "nested context in loop"
82+
_ = ctx
83+
}
84+
}
85+
86+
// Function literal detection is disabled: this must NOT be reported.
87+
func _() {
88+
ctx := context.Background()
89+
90+
f := func() {
91+
ctx = context.WithValue(ctx, "key", "val") // want "nested context in function literal"
92+
_ = ctx
93+
}
94+
f()
95+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//golangcitest:args -Efatcontext
2+
//golangcitest:config_path testdata/fatcontext_checkfunctionliterals.yml
3+
package testdata
4+
5+
import "context"
6+
7+
// Loop detection stays enabled: this MUST be reported.
8+
func _() {
9+
ctx := context.Background()
10+
11+
for i := 0; i < 10; i++ {
12+
ctx = context.WithValue(ctx, "key", i) // want "nested context in loop"
13+
_ = ctx
14+
}
15+
}
16+
17+
// Function literal detection is disabled: this must NOT be reported.
18+
func _() {
19+
ctx := context.Background()
20+
21+
f := func() {
22+
ctx = context.WithValue(ctx, "key", "val")
23+
_ = ctx
24+
}
25+
f()
26+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "2"
2+
3+
linters:
4+
settings:
5+
fatcontext:
6+
check-function-literals: false
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//golangcitest:args -Efatcontext
2+
//golangcitest:config_path testdata/fatcontext_checkloops.yml
3+
package testdata
4+
5+
import "context"
6+
7+
// Loop detection stays enabled: this MUST be reported.
8+
func _() {
9+
ctx := context.Background()
10+
11+
for i := 0; i < 10; i++ {
12+
ctx = context.WithValue(ctx, "key", i)
13+
_ = ctx
14+
}
15+
}
16+
17+
// Function literal detection is disabled: this must NOT be reported.
18+
func _() {
19+
ctx := context.Background()
20+
21+
f := func() {
22+
ctx = context.WithValue(ctx, "key", "val") // want "nested context in function literal"
23+
_ = ctx
24+
}
25+
f()
26+
}

0 commit comments

Comments
 (0)