golangci-lint
golangci-lint copied to clipboard
Add errgroupcheck linter
errgroupcheck analyzes code and reports any usage of golang.org/x/sync/errgroup that is missing any call to the Wait() func.
All the examples reported in the errgroup documentation showcase the correct usage of the Wait() func to wait for all the coroutines to complete before proceeding.
Missing the Wait() call allows the code to compile just fine, but yields unexpected results due to the coroutines running without any wait for termination.
Hey, thank you for opening your first Pull Request !
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.
- [x] The CLA must be signed
Pull Request Description
- [x] It must have a link to the linter repository.
- [x] It must provide a short description of 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).
- [x] It must have a valid license (AGPL is not allowed), and the file must contain the required information by the license, ex: author, year, etc.
- [x] It must use Go version <= 1.21
- [x] The linter repository must have a CI and tests.
- [x] It must use
go/analysis. - [x] It must have a valid tag, ex:
v1.0.0,v0.1.0. - [x] It must not contain
init(). - [x] It must not contain
panic(). - [x] It must not contain
log.Fatal(),os.Exit(), or similar. - [x] It must not modify the AST.
- [ ] It must not have false positives/negatives (the team will help to verify that).
- [x] It must have tests inside golangci-lint.
The Linter Tests Inside Golangci-lint
- [x] They must have at least one std lib import.
- [ ] They must have integration tests without configuration (default).
- [ ] They must have integration tests with configuration (if the linter has a configuration).
.golangci.next.reference.yml
- [x] The file
.golangci.next.reference.ymlmust be updated. - [x] The file
.golangci.reference.ymlmust NOT be edited. - [x] The linter must be added to the lists of available linters (alphabetical case-insensitive order).
enableanddisableoptions
- [ ] 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
- [x] The files (tests and linter) inside golangci-lint must have the same name as the linter.
- [x] The
.golangci.ymlof golangci-lint itself must not be edited and the linter must not be added to this file. - [x] The linters must be sorted in the alphabetical order (case-insensitive) in the
lintersdb/builder_linter.goand.golangci.next.reference.yml. - [x] The load mode (
WithLoadMode(...)):- if the linter uses
goanalysis.LoadModeSyntax-> noWithLoadForGoAnalysis()inlintersdb/builder_linter.go - if the linter uses
goanalysis.LoadModeTypesInfo, it requiresWithLoadForGoAnalysis()inlintersdb/builder_linter.go
- if the linter uses
- [x] The version in
WithSince(...)must be the next minor version (v1.X.0) of golangci-lint. - [x]
WithURL()must contain the URL of the repository.
Recommendations
- [x] The file
jsonschema/golangci.next.jsonschema.jsonshould be updated. - [x] The file
jsonschema/golangci.jsonschema.jsonmust NOT be edited. - [x] The linter repository should have a readme and linting.
- [x] The linter should be published as a binary (useful to diagnose bug origins).
- [ ] The linter repository should have a
.gitignore(IDE files, binaries, OS files, etc. should not be committed) - [x] A tag should never be recreated.
- [x] use
mainas the default branch name.
The golangci-lint team will edit this comment to check the boxes before and during the review.
The code review will start after the completion of those checkboxes (except for the specific items that the team will help to verify).
The reviews should be addressed as commits (no squash).
If the author of the PR is a member of the golangci-lint team, he should not edit this message.
This checklist does not imply that we will accept the linter.
Another yet case for uncalled
https://github.com/golangci/golangci-lint/pull/3348
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.
Seems like I signed the CLA but the status is not updating.
Is there anything I should do on top of following the provided signup link?
The email address you have used to commit is related to another account: https://github.com/AlexB-mgtc
So either you sign the CLA with this account or you recreate the commit with the account that open the PR
Thanks a lot, that solved it immediately.
Can you help me understand this?
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.
The only config available is to enable / disable the sole rule currently implemented.
Should I change the Default to be false and leave the value to true, or the opposite?
errgroupcheck:
# Check if any sync.errgroup.Group instance is missing a call to the Wait() func.
# Default: true
require-wait: true
The "# Default:" should be the default value. The value of the option should not be the default value.
# Default: true
require-wait: false
Does the longer work for errgroups stored as struct attribute? I have a use case where I’m creating a struct containing an errgroup in a "constructor", starting goroutines in a method of the struct and waiting in a third. What would that look like?