Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/vet: check for duplicate input to some binary ops #15586
[moved from #15570]
The check would be to look for expressions of the form (x BOP x), where:
These expressions are either redundant or have a constant value (with some very rare exceptions, like division and the smallest negative integer), which indicates that they are probably a mistake, and in any case would be better written in another way.
cc @robpike for opinions
cc @valyala in case you are interested in playing with more vet checks :)
Some data points from staticcheck:
The issue with those false positives is that they were hundreds of tests like these:
It's part of a Go interpreter project, with hundreds of code-gened tests like those, and the project had several forks.
If you ignore that particular project, you're left with about 20 false positives among all matches. Those are in generated code, in tests of