-
Notifications
You must be signed in to change notification settings - Fork 368
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
Switch linter from gometalinter to golangci-lint #176
Switch linter from gometalinter to golangci-lint #176
Conversation
638ee98
to
1f2e934
Compare
Codecov Report
@@ Coverage Diff @@
## master #176 +/- ##
=======================================
Coverage 50.91% 50.91%
=======================================
Files 13 13
Lines 711 711
=======================================
Hits 362 362
Misses 297 297
Partials 52 52
Continue to review full report at Codecov.
|
I think the commits from other rename PR got in here, too. Please rebase once the other one merges. |
1f2e934
to
41c0927
Compare
@ahmetb done |
Thanks for proposing this. I feel a bit uneasy about I think we shouldn't use megalinters like this one either. I'm not sure if the value add is enough. I'm trying to understand what other kubernetes projects use. Here's a search query: https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/kubernetes+%5Cblint+-file:vendor I suspect falling back to |
x/lint seems fairly popular https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/kubernetes+%22golint+%22+-file:vendor+count:1000 |
I'm not sure I understand your concerns about a metalinter, after all Would that address your worries? |
However, this would mean that users can't run the linter locally without installing golangci-lint manually. |
The part that annoyed me slightly is why there's a need for a very long general-purpose script ( Can't we just do wget+untar? I know their readme says "use this script" but I don't see the point just yet. |
Well I think the major argument for this script is convenience for users with different platforms and architectures. The script conveniently downloads the correct build for the current platform. As a new contributor, I would find it very nice if the linter would just work without having to manually download that binary from wherever that is. Admittedly, the script is large. But it does have a purpose. (Plus it also checks the hashsum) |
e0d422a
to
00f4513
Compare
Yeah but we could write our own install script and it would download if the binary is not in $PATH from the pinned version. I suspect the script would be very short and maintainable if we wrote it. Having wget/tar installed is a sensible expectation from any contributor so I’m not too worried about it. We already use sha256sum tooling in other scripts. |
Honestly, if we want to support contributors on different platforms, this script is the best way to go. After all, it's been tried and tested. I feel you major concern is having the script in the repo. Would it be an option to run it as |
e793c5d
to
c4d3120
Compare
/lgtm |
pkg/version/version.go
Outdated
@@ -15,8 +15,10 @@ | |||
// Package version contains the version information of the krew binary. | |||
package version | |||
|
|||
const unknown = "unknown" |
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 don't know why this is a linter error. It’s pretty common coding practice to have package level-const
s that are used throughout the code rather than duplicating it.
Another example is below. We should probably turn off this linter, it’s too aggressive.
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 don't quite understand what you mean. Travis and my machine think that the linter passes.
Do you mean that the constant should not be there and be inlined instead? This is what the linter complained about so I extracted the constants. If you think this is bad, I can see what linter needs to be disabled.
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.
ah, wait, I now see that the linter is actually trying to help us.
that said, it's erroneous. the "unknown" string on both gitCommit() and gitTag() methods mean different things. so they should not be shared by the same variable. we can do:
const unknownGitCommit = "unknown"
const unknownGitTag = "unknown"
similarly, the tests below actually test against v != unknown
which isn't good.
When we update the value of the const, we might be breaking the API (in this case we aren't), but the if test continues to test v != "unknown"
literal string comparison, it could catch that.
So I think we should still disable this particular linter.
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.
good catch. I disabled the goconst
linter. I think it would have allowed two occurrences of "unknown" in tests, but goconst
is not critical at all.
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.
@ahmetb can you take another look or close this PR?
pkg/version/version_test.go
Outdated
@@ -16,6 +16,8 @@ package version | |||
|
|||
import "testing" | |||
|
|||
const commitSha = "abcdef" |
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.
Can you revert changes to this file? We since removed this linter.
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.
Sure. PTAL
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahmetb, corneliusweig 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 |
Close #174
Based on #178