-
Notifications
You must be signed in to change notification settings - Fork 4
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
Doesn't work with multiple packages #31
Comments
Actually, there's a test that expects this wrong behaviour right now:
Also, my proposed solution would break these test cases:
So I think a different solution is needed... the type analysis can't be skipped entirely :( |
Adding a check specifically for array type to make sure nil slices are always allowed is one solution to the slice issue: if n.checkedTypes.Contains(anyType) {
if _, ok := t.(*ast.ArrayType); ok {
return false
}
return true
} I don't know if I agree with the other test cases though. Why shouldn't nil |
Hi! Thank you for issue. Quote from README:
Are you interested in this feature? |
Yeah, I like the pattern of using sentinel errors and I want to make sure we can detect the use of nil pointers as "not found" errors more reliably everywhere. |
@vikstrous2 new release has been published, thanks! Wait for it in the nearest release of |
This is amazing! I can't wait to try it out in golangci-lint! It seems to work so far |
To reproduce, add this to the examples:
And add this to a new package under "examples":
Reading the code of the linter, the package of the type is not considered in the analysis and
*ast.SelectorExpr
is not traversed inisDangerNilType
, so only types form the same package are analyzed.One way to "fix" this might be to create a config that bypasses this type based analysis entirely by saying "all types should be checked". That still wouldn't work if a custom config is given and typed based analysis is still desired, but I think it would work for most users.
The text was updated successfully, but these errors were encountered: