-
Notifications
You must be signed in to change notification settings - Fork 103
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
golangci-lint workflow #262
Conversation
…ything that was inside helper_test.go and remove unnecesary use of formatting
…ngci-lint does not see it
…unctions from test files
Are we sure this works as intended? I am running
|
@omarismail Hey Omar! About this #262 (comment) , are you running a different lint library locally or did you alias |
…i-lint 1.42 to match local environment
…eprecated and archive, and instead use revive: https://github.com/hashicorp/go-tfe/pull/262/checks?check_run_id=3738237150
I was able to surface most of the errors that you'd see with Lines 4 to 8 in cabf350
I fixed the issues reported by those libraries locally, so in the latest golangci-lint github workflow you will not see any errors in the output. But you can take a look at the previous workflow run to check for the errors I fixed: https://github.com/hashicorp/go-tfe/actions/runs/1284596686 Let me know your thoughts! @omarismail |
.golangci.yml
Outdated
timeout: 5m | ||
linters: | ||
enable: | ||
- gosimple |
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.
Hmm, the docs say that this gosimple
plus others are enabled by default. Part of that list includes errcheck. But when I run errcheck -verbose ./...
locally, i get
go-tfe % errcheck -verbose ./...
checking github.com/hashicorp/go-tfe
checking github.com/hashicorp/go-tfe/examples/workspaces
checking github.com/hashicorp/go-tfe
checking github.com/hashicorp/go-tfe.test
checking github.com/hashicorp/go-tfe/examples/organizations
ip_ranges.go:83:23: (io.Closer).Close defer resp.Body.Close()
logreader.go:76:23: (io.Closer).Close defer resp.Body.Close()
tfe.go:410:17: (io.Closer).Close resp.Body.Close()
tfe.go:594:23: (io.Closer).Close defer resp.Body.Close()
It doesn't seem like these are enabled by default then? I think we should add all those that are supposed to be enabled by default explicitly here. So
linters:
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
@omarismail Ok, I think I know what is going on with
And now when we run
Errors, yay! |
…ditional configuration to errcheck because some of their features are disable by default
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.
lgtm once tests pass
Description
This PR is meant to address an Asana ticket that requests to add a lint library using Github Actions that can be trigger every time someone opens a PR against
go-tfe
.After creating the github action workflow, golangci-lint displayed its errors here: https://github.com/hashicorp/go-tfe/pull/262/checks?check_run_id=3681121701
I ignored the recommendations related to "unused" code coming from helper_test.go because the
unused
library pulled by Golangci-lint does not see that those test functions are being used in other integrations tests within the same package.This issue was reported last year but it sounds like that golangci-lint may not cover all edge cases around that external
unused
library: golangci/golangci-lint#791It seemed like the simple solution would be to configure our golangci.yml to ignore the
unused
library for test files.Documentation on Golangci-lint: https://golangci-lint.run/usage/configuration/