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

bazel: perform staticcheck checks in nogo #73572

Merged
merged 1 commit into from
Dec 13, 2021

Conversation

rickystewart
Copy link
Collaborator

Add a new binary generate-staticcheck, part of dev generate bazel,
that creates a package in build/bazelutil/staticcheckanalyzers
capturing a single staticcheck check. Then we capture the list of
analyzers in build/bazelutil/staticcheckanalyzers/def.bzl and add all
those checks to nogo.

However, we can't directly use the Analyzers provided by the upstream
library, because they report all violations regardless of
lint:ignore directives. In order to address this we add a helper
library at pkg/testutils/lint/passes/staticcheck that munges the
Analyzers to additionally pull the lint:ignore directives and ignore
any reported diagnostics that correspond to a lint:ignore.

This follows the example set by https://github.com/sluongng/staticcheck-codegen,
but we don't directly use that code, since we need to inject our own
stuff and we want to make sure the content here is pinned to the right
version of staticcheck.

We run the staticcheck and simple checks.
stylecheck is still broken: #73568

Closes #68496.

Release note: None

@rickystewart rickystewart requested a review from rail December 7, 2021 21:17
@rickystewart rickystewart requested a review from a team as a code owner December 7, 2021 21:17
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@rail rail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 3 of 252 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @rail)

Add a new binary `generate-staticcheck`, part of `dev generate bazel`,
that creates a package in `build/bazelutil/staticcheckanalyzers`
capturing a single `staticcheck` check. Then we capture the list of
analyzers in `build/bazelutil/staticcheckanalyzers/def.bzl` and add all
those checks to `nogo`.

However, we can't directly use the `Analyzer`s provided by the upstream
library, because they report *all* violations regardless of
`lint:ignore` directives. In order to address this we add a helper
library at `pkg/testutils/lint/passes/staticcheck` that munges the
`Analyzer`s to additionally pull the `lint:ignore` directives and ignore
any reported diagnostics that correspond to a `lint:ignore`.

This follows the example set by https://github.com/sluongng/staticcheck-codegen,
but we don't directly use that code, since we need to inject our own
stuff and we want to make sure the content here is pinned to the right
version of `staticcheck`.

We run the `staticcheck` and `simple` [checks](https://staticcheck.io/docs/checks).
`stylecheck` is still broken: cockroachdb#73568

Closes cockroachdb#68496.

Release note: None
@rickystewart
Copy link
Collaborator Author

bors r=rail

@craig
Copy link
Contributor

craig bot commented Dec 13, 2021

Build succeeded:

@craig craig bot merged commit d411bd0 into cockroachdb:master Dec 13, 2021
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 this pull request may close these issues.

bazel: TestLint/TestStaticCheck broken under Bazel
3 participants