-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: x/tools/go/analysis/testchecker: analysis driver for tests #71478
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
Comments
I think I should fold this into #61336 |
Interesting timing: we have been having a lot of conversations recently about the possibility of dynamically loaded analyzers that live in the module, enabling projects to define their own rules, either for internal housekeeping or to help their users detect misuse of their APIs. If done right, merely reading code that depends on package P would cause your editor to highlight misuses of P's API. Obviously there are a lot of technical problems to solve--compiling or interpreting; security; performance; UX; accessibility of the notation to non-experts--but a dynamic system would also be a solution to this problem. |
I also saw a small ecosystem around linting terraform providers (which are usually a lot of crud code to turn declarative IaC to api calls) built around https://github.com/bflad/tfproviderlint Otherwise, most of what I've seen is around project internal housekeeping. |
Proposal Details
I propose a new helper for running
x/tools/go/analysis/passes
over the files in a module, and reporting the results as a test pass/fail.Example usage:
Go has a rich ecosystem of static analysis, much of which is built on top of
x/tools/go/analysis
.While these can aide developers while authoring code, like when integrated into gopls https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md , many projects also enforce a common set of checks during CI.
Today, there are a variety of options to do that, for example, a random sampling:
Go already runs a set of vet checks by default during
go test
, these are high confidence checks that apply to everyone. Individual projects can usually be stricter and enforce more checks by default.I think a helper to directly integrate linters into tests can ease the sprawl of complexity in ensuring projects continue to adhere to their desired quality gates.
The text was updated successfully, but these errors were encountered: