-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: detect potential issues with struct pointers #36
Conversation
This is tricky. We should probably hide it behind a configuration of some sort (at least at first) because I have the feeling that it may trigger a lot. |
testdata/src/example.go
Outdated
return func(r *Container) { | ||
ctx := r.Ctx | ||
ctx = context.WithValue(ctx, "key", "val") | ||
r.Ctx = ctx // want "nested context in function literal" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This already triggers, without any of the linter changes in this PR.
testdata/src/example.go
Outdated
func blah(r *Container) { | ||
ctx := r.Ctx | ||
ctx = context.WithValue(ctx, "key", "val") | ||
r.Ctx = ctx // want "potential nested context in function declaration" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new.
Do we really want this? I feel like we're onto something here: this can definitely be the source of a fat context (see #34 (comment)), but it can also be pretty harmless, depending on how the function is called.
I'd be tempted to say we should at least signal it with a specific message, and let the user decide how they want to handle it.
Or can we rely on the fact that @ldez do you have insights maybe? I wouldn't want to impose you with a surge of unwanted reports. |
It's better to have a linter option: by default, I expect 0 false-positives. |
326edc3
to
5030c3a
Compare
dbcea46
to
3f63d5a
Compare
Thanks, noted 👍🏻 |
bcd6581
to
d01a98f
Compare
d01a98f
to
5cd7b35
Compare
Related to #34