Skip to content
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

Does not pass nilness analyzer #507

Closed
uhthomas opened this issue Mar 11, 2022 · 3 comments · Fixed by #510
Closed

Does not pass nilness analyzer #507

uhthomas opened this issue Mar 11, 2022 · 3 comments · Fixed by #510

Comments

@uhthomas
Copy link

The package does not pass the nilness analyzer.

❯ go run golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness@latest ./...
-: impossible condition: non-nil == nil
/home/thomas/code/github.com/getkin/kin-openapi/openapi3/schema.go:1418:64: tautological condition: non-nil != nil
exit status 3

It would be nice to fix this :)

@fenollp
Copy link
Collaborator

fenollp commented Mar 13, 2022

Hi @uhthomas thanks for bringing this tool to our attention.
I'm having issues understanding the first error -: impossible condition: non-nil == nil could you help?
A cursory search did not prove fruitful: https://github.com/golang/go/search?q=nilness+-%3A+impossible+condition%3A+non-nil+%3D%3D+nil&type=issues
Maybe we can both work on making this report easier to act upon.

@uhthomas
Copy link
Author

Hey @fenollp, that is strange. It looks like golang/go#31008 is the correct issue for this. Funnily enough, this repository is mentioned in a linked issue bazel-contrib/rules_go#2480.

The culprit is a nil check in visitJSON.

case nil:
return schema.visitJSONNull(settings)

The nilness analzyer passes when these two lines are removed.

I think #510 is a good idea, but it might be even better to use golangci-lint. What do you think?

Hope this helps! :)

@fenollp
Copy link
Collaborator

fenollp commented Mar 13, 2022

Thanks for finding the right issue and root causing this.

I'm down to add more linters and golangcilint is a good collection but false positives waste too much time.
I'd be happy to review a PR that adds a CI job with a minimal amount of linters (i.e. the ones that are surefire)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants