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

Run more linters with golangci-lint #1244

Open
oxddr opened this issue May 8, 2020 · 20 comments
Open

Run more linters with golangci-lint #1244

oxddr opened this issue May 8, 2020 · 20 comments
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@oxddr
Copy link
Contributor

oxddr commented May 8, 2020

Currently we run only golint and gofmt. We should at least enable linters which are enabled by default in golangci-lint:

$ golangci-lint help linters
Enabled by default linters:
deadcode: Finds unused code [fast: true, auto-fix: false]
errcheck: Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: true, auto-fix: false]
gosimple (megacheck): Linter for Go source code that specializes in simplifying a code [fast: true, auto-fix: false]
govet (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: true, auto-fix: false]
ineffassign: Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
staticcheck (megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: true, auto-fix: false]
structcheck: Finds unused struct fields [fast: true, auto-fix: false]
typecheck: Like the front-end of a Go compiler, parses and type-checks Go code [fast: true, auto-fix: false]
unused (megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
varcheck: Finds unused global variables and constants [fast: true, auto-fix: false]

Enabling some of them (I've checked errcheck and deadcode) would require fixing outstanding issues.

Work here should be done incrementally, one-by-one.

/good-first-issue
/help-wanted

@k8s-ci-robot
Copy link
Contributor

@oxddr:
This request has been marked as suitable for new contributors.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-good-first-issue command.

In response to this:

Currently we run only golint and gofmt. We should at least enable linters which are enabled by default in golangci-lint:

$ golangci-lint help linters
Enabled by default linters:
deadcode: Finds unused code [fast: true, auto-fix: false]
errcheck: Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: true, auto-fix: false]
gosimple (megacheck): Linter for Go source code that specializes in simplifying a code [fast: true, auto-fix: false]
govet (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: true, auto-fix: false]
ineffassign: Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
staticcheck (megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: true, auto-fix: false]
structcheck: Finds unused struct fields [fast: true, auto-fix: false]
typecheck: Like the front-end of a Go compiler, parses and type-checks Go code [fast: true, auto-fix: false]
unused (megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
varcheck: Finds unused global variables and constants [fast: true, auto-fix: false]

Enabling some of them (I've checked errcheck and deadcode) would require fixing outstanding issues.

Work here should be done incrementally, one-by-one.

/good-first-issue
/help-wanted

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.

@k8s-ci-robot k8s-ci-robot added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels May 8, 2020
@bitcodr
Copy link

bitcodr commented May 10, 2020

@oxddr I'd like to work on it

@oxddr
Copy link
Contributor Author

oxddr commented May 11, 2020

@bitcodr that's great to hear. I think the best way to proceed is to pick up one of the linters from above (e.g. deadcode of errcheck), enable it and fix all reported issue and send me a PR for a review.

@wfernandes
Copy link

wfernandes commented Jun 19, 2020

Hey @bitcodr Are you perhaps still working on this? If so feel free to /assign this issue. I was just looking for places to contribute and didn't know if this issue was taken or not. Thanks.

@satishbellapu
Copy link

/assign

@wojtek-t
Copy link
Member

Adding gofmt would be especially useful.

@satishbellapu
Copy link

@oxddr Cleared errors for few of the modules, need some help on "clusterloader2" on few errors,

ERRO Running error: deadcode: analysis skipped: errors in package: [.../perf-tests/clusterloader2/pkg/chaos/nodes.go:109:52: cannot use k.client (variable of type kubernetes.Interface) as kubernetes.Interface value in argument to util.GetSchedulableUntainedNodes: wrong type for method AdmissionregistrationV1 .../perf-tests/clusterloader2/pkg/chaos/nodes.go:114:52

@wojtek-t
Copy link
Member

@satishbellapu - this looks strange.
But let's work iteratively on it. Feel free to send a PR that is fixing just some of the errors.
And then the pattern should be:

  • extend the presubmit to check gofmt, but make it not fail the test (just informative)
  • we will be working on fixing it while having it running
  • once we fix everything, we will make it blocking

@kushthedude
Copy link
Contributor

kushthedude commented Aug 25, 2020

Hey @wojtek-t, I would like to fix it! Is this up for grabs?

@wojtek-t
Copy link
Member

I didn't see any actions from @satishbellapu for last month, so it seems fine.

@kushthedude
Copy link
Contributor

/assign

@kushthedude
Copy link
Contributor

Errcheck has been added, Deadcode linter on the way!

@kushthedude
Copy link
Contributor

Hi @wojtek-t with #1448, we will have six outstanding linters running with golangci-lint. Apart from them I would like to suggest staticcheck & goimport to be enabled, what do you suggest do we need them or we are fine without them?

@wojtek-t
Copy link
Member

wojtek-t commented Sep 1, 2020

I think we're fine without them (at least now). We can add them later...

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 30, 2020
@wojtek-t
Copy link
Member

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 30, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 28, 2021
@wojtek-t
Copy link
Member

wojtek-t commented Mar 1, 2021

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 1, 2021
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 30, 2021
@wojtek-t
Copy link
Member

/remove-lifecycle stale
/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

No branches or pull requests

8 participants