pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.14k stars 5.83k forks source link

Make linter facter by enabling bazel nogo to implement fast incremental linter #35345

Closed hawkingrei closed 2 years ago

hawkingrei commented 2 years ago

Enhancement

nogo build-time code analysis

nogo is a tool that analyzes the source code of Go programs. It runs alongside the Go compiler in the Bazel Go rules and rejects programs that contain disallowed coding patterns. In addition, nogo may report compiler-like errors.

nogo is a powerful tool for preventing bugs and code anti-patterns early in the development process. It may be used to run the same analyses as vet, and you can write new analyses for your own code base.

tisonkun commented 2 years ago

Could you add a link to nogo and try to prepare a table comparing nogo and govet, pros and cons?

hawkingrei commented 2 years ago

Could you add a link to nogo and try to prepare a table comparing nogo and govet, pros and cons?

This document is about nogo

hawkingrei commented 2 years ago

Could you add a link to nogo and try to prepare a table comparing nogo and govet, pros and cons?

I think the advantage of nogo is that it has a good mechanism to get cache results and share the cache anywhere. the disadvantage of it is that it makes a person manage the linter by code. here is an example from cockroach. and this is a library to do it.

hawkingrei commented 2 years ago

BTW, I have a plan to use Bazel nogo and golang.Ast to check the problem that RecordSet is not closed in the test like https://github.com/pingcap/tidb/pull/35373.

hawkingrei commented 2 years ago

We have removed golangci-linter in the CI. The performance of the linter has sped up 10x. We can close this issue.