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

🐛 Ignore ireturn, and varnamelen linters #102

Merged
merged 2 commits into from
Nov 10, 2021

Conversation

cardil
Copy link
Contributor

@cardil cardil commented Nov 10, 2021

Changes

  • 🐛 Ignore ireturn, and varnamelen linters

/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:

# The longest distance, in source lines, that is being considered a "small scope." (defaults to 5)
# Variables used in at most this many lines will be ignored.
max-distance: 12
# The minimum length of a variable's name that is considered "long." (defaults to 3)
# Variable names that are at least this long will be ignored.
min-name-length: 2

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.

@knative-prow-robot knative-prow-robot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 10, 2021
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Nov 10, 2021
@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 10, 2021
@cardil
Copy link
Contributor Author

cardil commented Nov 10, 2021

/cc @dsimansk

@codecov
Copy link

codecov bot commented Nov 10, 2021

Codecov Report

Merging #102 (4608dd5) into main (43ff059) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 43ff059...4608dd5. Read the comment docs.

@knative-prow-robot knative-prow-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 10, 2021
@@ -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
Copy link
Contributor Author

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

Copy link
Contributor

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 🙈

Copy link
Contributor Author

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.

Copy link
Contributor

@dsimansk dsimansk left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 10, 2021
@knative-prow-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot merged commit 653e101 into knative-extensions:main Nov 10, 2021
@cardil cardil deleted the bugfix/98-liters branch November 10, 2021 12:19
@cardil
Copy link
Contributor Author

cardil commented Nov 19, 2021

/cherrypick release-0.26
/cherrypick release-1.0

@knative-prow-robot
Copy link

@cardil: new pull request created: #109

In response to this:

/cherrypick release-0.26
/cherrypick release-1.0

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.

@cardil
Copy link
Contributor Author

cardil commented Nov 19, 2021

/cherrypick release-1.0

@knative-prow-robot
Copy link

@cardil: new pull request created: #110

In response to this:

/cherrypick release-1.0

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.

@cardil
Copy link
Contributor Author

cardil commented Nov 20, 2021

/cherrypick release-0.25

@knative-prow-robot
Copy link

@cardil: new pull request created: #111

In response to this:

/cherrypick release-0.25

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check linter warnings/errors
3 participants