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

feat: add gomegacheck #3279

Closed
wants to merge 1 commit into from
Closed

Conversation

ecordell
Copy link

@ecordell ecordell commented Oct 5, 2022

This adds the gomegacheck linter.

Source: https://github.com/gardener/gardener/tree/master/hack/tools/gomegacheck
Discussion of the problem: onsi/gomega#561

Async assertions written with gomega don't actually assert anything unless there is an assertion on the the entire async block. It can be easy to miss, since there will often be one or more assertions inside the async block.

This linter was written by @timebertt, who has given permission to include it here.

@ldez
Copy link
Member

ldez commented Oct 5, 2022

In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.

Pull Request Description

  • It must have a link to the linter repository.
  • It must provide a short description about the linter.

Linter

  • It must not be a duplicate of another linter or a rule of a linter. (the team will help to verify that)
  • It must have a valid license and the file must contain the required information by the license, ex: author, year, etc.
  • The linter repository must have a CI and tests.
  • It must use go/analysis.
  • It must have a valid tag, ex: v1.0.0, v0.1.0.
  • It must not contain init().
  • It must not contain panic(), log.fatal(), os.exit(), or similar.
  • It must not have false positives/negatives. (the team will help to verify that)
  • It must have tests inside golangci-lint.

The Linter Tests Inside Golangci-lint

  • They must have at least one std lib import.
  • They must work with T=<name of the linter test file>.go make test_linters. (the team will help to verify that)

.golangci.reference.yml

  • The linter must be added to the list of available linters (alphabetical case-insensitive order).
    • enable and disable options
  • If the linter has a configuration, the exhaustive configuration of the linter must be added (alphabetical case-insensitive order)
    • The values must be different from the default ones.
    • The default values must be defined in a comment.
    • The option must have a short description.

Others Requirements

  • The files (tests and linter) inside golangci-lint must have the same name as the linter.
  • The .golangci.yml of golangci-lint itself must not be edited and the linter must not be added to this file.
  • The linters must be sorted in the alphabetical order (case-insensitive) in the Manager.GetAllSupportedLinterConfigs(...) and .golangci.reference.yml.
  • The load mode (WithLoadMode(...)):
    • if the linter doesn't use types: goanalysis.LoadModeSyntax
    • goanalysis.LoadModeTypesInfo required WithLoadForGoAnalysis() in the Manager.GetAllSupportedLinterConfigs(...)
  • The version in WithSince(...) must be the next minor version (v1.X.0) of golangci-lint.

Recommendations

  • The linter should not use SSA. (currently, SSA does not support generics)
  • The linter repository should have a readme and linting.
  • The linter should be published as a binary. (useful to diagnose bug origins)

The golangci-lint team will edit this comment to check the boxes before and during the review.

This checklist does not imply that we will accept the linter.

@ldez ldez added the linter: new Support new linter label Oct 5, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Oct 5, 2022

Hey, thank you for opening your first Pull Request !

@CLAassistant
Copy link

CLAassistant commented Oct 5, 2022

CLA assistant check
All committers have signed the CLA.

@ldez
Copy link
Member

ldez commented Oct 5, 2022

@timebertt @ecordell it's possible to extract the linter into a dedicated repo?

@ldez ldez added the blocked Need's direct action from maintainer label Oct 5, 2022
@ldez
Copy link
Member

ldez commented Oct 11, 2022

@timebertt @ecordell any news?

@ecordell
Copy link
Author

ecordell commented Oct 11, 2022

how important is it that it be its own repo? @timebertt mentioned in the linked thread that it would be okay to move it, but wouldn't have time to do it. I can take a stab at it but I probably won't be able to get to it for a couple of days.

@ldez
Copy link
Member

ldez commented Oct 11, 2022

I can take a stab at it but I probably won't be able to get to it for a couple of days.

Not a problem we can wait.

@nunnatsa
Copy link
Contributor

nunnatsa commented Dec 6, 2022

@ecordell, #3369 also deals with gomega. Any chance to combine them?

@ldez ldez added the feedback required Requires additional feedback label Dec 17, 2022
@ldez
Copy link
Member

ldez commented Dec 26, 2022

I close this PR:

@ldez ldez closed this Dec 26, 2022
@ldez ldez added declined and removed feedback required Requires additional feedback blocked Need's direct action from maintainer labels Dec 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
declined linter: new Support new linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants