-
Notifications
You must be signed in to change notification settings - Fork 22
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
🐛 Ignore ireturn, and varnamelen linters #102
🐛 Ignore ireturn, and varnamelen linters #102
Conversation
/cc @dsimansk |
Codecov Report
@@ Coverage Diff @@
## main #102 +/- ##
=======================================
Coverage 69.92% 69.92%
=======================================
Files 31 31
Lines 828 828
=======================================
Hits 579 579
Misses 192 192
Partials 57 57 Continue to review full report at Codecov.
|
b039f3b
to
4608dd5
Compare
@@ -106,7 +106,7 @@ jobs: | |||
if: steps.golangci_configuration.outputs.files_exists == 'true' | |||
uses: golangci/golangci-lint-action@v2 | |||
with: | |||
version: v1.42 | |||
version: v1.43 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is taken from #99
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope that won't break update actions 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it won’t.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cardil, dsimansk The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cherrypick release-0.26 |
@cardil: new pull request created: #109 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cherrypick release-1.0 |
@cardil: new pull request created: #110 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cherrypick release-0.25 |
@cardil: new pull request created: #111 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Changes
/kind bug
Fixes #98
Justification
I did a closer look at those two new rules that came with the latest release of golangci-lint: ireturn and varnamelen, and I believe it's not worth pursuing compliance with them. Detailed evaluation below.
ireturn evaluation
The ireturn linter ensures you don't return interfaces, but rather a concrete type. In general, that's good practice when the struct is public - the caller might be interested in struct fields, not only the behavior (interface). But, ireturn fires also in case when the returned type is private - linter even advise such change in its README doc. Doing that violates another linter - revive, and it's cumbersome to caller, not giving him any benefits from it.
There are other cases that seem reasonable to skip, like:
Also, worth citing Rob Pike on this go-proverbs/go-proverbs.github.io#37 (comment)
varnamelen evaluation
The varnamelen forces use of names size 3+ for most of the variables. It applies to all places where the function is longer than 5 lines, so almost all places. That makes it really hard to use, as Go code tends to have short packages, like
git
,file
,metadata
,plugin
, and so 3+ length variable names tend to interfere a lot with those packages.I've experimented a bit with different settings:
And still, I got 10 places that are not compliant, in such small project. Manually reviewing them, I don't see a huge benefit of changing those names. It doesn't improve readability IMHO.