-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add nilnil linter #2236
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
Add nilnil linter #2236
Conversation
25ddded
to
7274280
Compare
Hello, I'm not sure to agree with the rule behind this linter. And currently, it produces too many false positives, an example: package foobar
import (
"net/url"
)
type Foo struct {
URL *url.URL
}
func example(val string) (*Foo, error) {
endpoint, err := url.Parse(val)
if err != nil {
return nil, err
}
if endpoint.Host != "example.com" {
return nil, nil
}
return &Foo{URL: endpoint}, nil
}
|
What's false positive here, you do return Also I'm not sure we should reject linters because it's not useful for everyone. I would say that a big part of the linters are super opinionated and will never be enabled by the vast majority. That's also why we don't enable new linters by default. |
It's not my point, I tested this linter on several real codebases, and it produces, from my point of view, a lot of false positives. The cases where we need to not return an error are commons. I have just "blocked" the PR and expressed my doubts, then the discussion is still opened.
We enable the new linters by default when a user uses |
I think this is similar to
Yeah I know and that's why I contributed to it with my thoughts to the discussion. 😃 Would of course be nice if more people had opinions about this as well.
I think the outcome of the discussion(s) to keep |
@ldez, what exactly is false positive? And what behavior do you expect? Please, see linter readme and examples for more details. There is no technical way to determine when it is valid If you use |
7274280
to
f8a9f11
Compare
What I consider as false-positive you consider that as a feature, then there is no false-positive. |
@ldez thank u! In fact, the linter did not appear out of nowhere. Using in my working projects
I myself would like to get more evidence base besides personal experience and common sense and I will be grateful for it.
So no problem. I just awaiting for feedback from other reviewers. @bombsimon, thank u for support :) |
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.
LGTM
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.
💯
https://github.com/Antonboom/nilnil