-
Notifications
You must be signed in to change notification settings - Fork 15
Update: add golangci configuration and workflow for better go linting #78
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
Conversation
|
We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story. The labels on this github issue will be updated when the story is started. |
rroberts2222-zz
left a comment
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.
Lint test is failing because "Error return value of lw.Write is not checked (errcheck)"
Located in internal/command/query.go, internal/command/tail.go, and internal/command/meta.go
* [golangci](https://golangci-lint.run/) is a common and useful Go linter aggregator that is fast, more opinionated / frequently updated than `go vet`, and it provides a nice output. * `.golangci.yml` describes our current configuration of golangci. * The new `lint` job in the Go workflow will run golangci on PRs and pushes. * golangci can be run manually: `golangci-lint run ./...`.
If the cf CLI is set to be insecure then we would want to copy that setting, even though it's not ideal. Therefore we should ignore gosec warning `G402`, which looks for bad TLS connection settings, and always triggers because we might set TLS.InsecureSkipVerify to true.
golang.org/x/crypto/ssh/terminal is deprecated and has been moved to golang.org/x/term.
Remove two unused vars: `invalidTimestampResponse` and `invalidPayloadResponse`.
gocyclo measures cyclomatic complexity, which is: > a code quality metric which can be used to identify code that needs refactoring. It measures the number of linearly independent paths through a function's source code. The default min-complexity that gocyclo ships with is 30. However, the folks managing golangci currently recommend setting this factor between 10-20.
The error is not checked anywhere, so there's not much point in returning it. We probably should go back and do check this error at some point.
Several functions are too complex to pass the recommended `min-complexity` settings. This gets golang-ci closer to passing with our current code. We should come back and lower the complexity + refactor the offending functions at some point.
|
This is as close as we're going to get to passing |
rroberts2222-zz
left a comment
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
Description
Add a golangci configuration, and add a job to the Go workflow to lint our code while using it.
go vetis great.golangci-lintmay be better 😁 .Type of change
Testing performed?
Checklist:
mainbranch, or relevant version branch