golangci-lint
golangci-lint copied to clipboard
feat: add interfacebloat
A linter that checks the number of methods on an interface. https://github.com/sashamelentyev/interfacebloat
In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.
Pull Request Description
- [x] It must have a link to the linter repository.
- [x] It must provide a short description about the linter.
Linter
- [x] 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 and the file must contain the required information by the license, ex: author, year, etc.
- [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()
,log.fatal()
,os.exit()
, or similar. - [x] 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.
- [x] 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
- [x] The linter must be added to the list of available linters (alphabetical case-insensitive order).
-
enable
anddisable
options
-
- [x] 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.yml
of 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
Manager.GetAllSupportedLinterConfigs(...)
and.golangci.example.yml
. - [x] The load mode (
WithLoadMode(...)
):- if the linter doesn't use types:
goanalysis.LoadModeSyntax
-
goanalysis.LoadModeTypesInfo
requiredWithLoadForGoAnalysis()
in theManager.GetAllSupportedLinterConfigs(...)
- if the linter doesn't use types:
- [x] The version in
WithSince(...)
must be the next minor version (v1.X.0
) of golangci-lint.
Recommendations
- [x] 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.
What do you call the length of an interface? :thinking:
Can you improve your readme?
- add detailed explanation
- add exemples
I mean count of methods in interface
What is the rule that you want to apply? is it limit the number of methods in an interface? Can you explain why (please provide links to documentation)?
Yes, limit the number of methods in an interface interface bloat (fat interface) - it's anti-pattern
https://en.wikipedia.org/wiki/Interface_bloat https://stackoverflow.com/questions/1894021/what-is-interface-bloat
So now, you have to improve your readme with the links and examples.
@ldez I add short description and links
https://github.com/sashamelentyev/interfacebloat/pull/1
The test failure is related to https://github.com/golangci/golangci-lint/pull/3104/commits/6e756cb7b51d399a5a6cf8b3a49030db910d6305 and fixed by #3118