-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
github checks: gometalinter structcheck/varcheck/deadcode #3085
Conversation
conversation from #3084
|
My understanding is, that every developer can run locally these checks. So I suggest to add these checks in the project and make them usable with e.g. These checks should run on jenkins with |
Potentially, as a general blanket check yet, though in the PR's it might be nice to have detailed checks. |
If it's structcheck we want, I think we should pull in https://github.com/opennota/check directly. I use the metalinter now and then, but find it way too noisy in the general case. |
The checks that we want to run always are run as part of regular |
I see metalinter as a frontend. I just tried structcheck directly and I has inconvinient path handling. I rather prefer metalinter with a selected set of linters. Evaluate one by one. |
That's fair. In that case I'd focus on the tool that you used for the dead code analysis for example, as that has proven itself in finding stuff that we've left behind. :) But regardless, the preferred way to me would be to hook into the place where we do the current vet and lint calls. Verify that that it (the function in build.go) correctly understands the difference between an error because the linter isn't installed and an error because the linter found something wrong - fail the build in the latter case. I don't expect the exit code 3 check to work on metalinter not being installed, for example. |
@@ -230,17 +235,26 @@ func main() { | |||
clean() | |||
|
|||
case "vet": |
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.
Maybe we can merge vet
and lint
command as only lint
?
Why is |
Lint is informational and not meant to be 100% enforced. It is however run as part of the pr-build step, it just doesn't fail the build. |
I'd like to see it enforced, so |
|
||
func (g *gometalinter) deadline(deadlineInSeconds int) *gometalinter { | ||
g.deadlineInSeconds = deadlineInSeconds | ||
return g |
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 feels so java.
Yet if we go this way, I'd do this on a non-pointer receiver.
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 feels so java.
Do you feel bad vibrations? ;)
} | ||
g.verifiedInstallation = true |
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 will still verify it multiple times, as the methods are no longer pointer receivers, and you have multiple instances of the objects anyway.
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 mixed. So this should still be valid.
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 understand.
How is performing existence checks once before the whole song less beneficial than constructing 3 objects, chaining them multiple times and then calling run just to do nothing?
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.
no, due to creating new instances, this is b*shit. I need to fix it. Too late yesterday.
I'd like to keep it encasulated and maybe checked multiple times. This should be a performance penalty of 200ms(?) each run. Else it become cluttered.
If it wasn't in the build tool it would have been a different thing.
@calmh sometimes it feels to have too few changes to extra do a pull request. But lets have a try ;) |
@calmh Thought maybe baby commits makes the diff easier. But seems you review the total diff. |
@st-jenkins retest plz |
@st-jenkins whitelist |
@st-jenkins retest this please |
Anything left? |
Looks fine, but I'll leave for @calmh to merge |
ok |
Lgtm apart from being too noisy. We don't print or time any other checks so no reason to do it here either, and the "no output = no issues" property is convenient when using this as a check from other places. Remove that and merge. :) |
@st-review merge build.go: add gometalinter to lint runs |
Purpose
static code analysis: this add checks to
build.go
:see more on https://github.com/alecthomas/gometalinter
Testing