Add golangci-lint CI action, fix gosimple, govet + unused lint errors#1127
Merged
timvaillancourt merged 3 commits intogithub:masterfrom May 31, 2022
Merged
Conversation
golangci-lint, fix gosimple, govet + unused linter errorsgolangci-lint CI action, fix gosimple, govet + unused lint errors
Collaborator
Author
|
EDIT: never mind, I don't have access to force-merge a PR with incomplete required jobs |
Collaborator
Author
ghost
approved these changes
May 31, 2022
Done, mystery solved about where those jobs were configured - thanks! I've run the CI build now so you should be all good to merge once that's done 👍 |
Collaborator
Author
@dm-2 👋 and thanks! |
ghost
pushed a commit
that referenced
this pull request
Jul 7, 2022
…t errors (#1127) * Add `golangci-lint`, fix `gosimple`, `govet` and `unused` linter complaints * Go 1.16 * Update copyright dates
Closed
ghost
pushed a commit
that referenced
this pull request
Jul 7, 2022
…t errors (#1127) * Add `golangci-lint`, fix `gosimple`, `govet` and `unused` linter complaints * Go 1.16 * Update copyright dates
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a
golangci-lintconfig and GitHub Action in order to lint thegh-ostcodeCurrently nothing is validating the cleanliness/best-practices of our Golang code
Initially only these linters are enabled:
gosimplegovetunusedAnd I plan to create follow-up PRs to enable the remaining linters
Introducing these 3 x linters triggered these complaints that are resolved by this PR:

Linter errors raised/resolved:
func REDACTED is unused (unused)S1025: should use String() instead of fmt.Sprintf (gosimple)S1039: unnecessary use of fmt.Sprintf (gosimple)S1019: should use make([]string, len(uniqueKeyColumnNames)) instead (gosimple)S1023: redundant return statement (gosimple)S1007: should use raw string (...) with regexp.MustCompile to avoid having to escape twice (gosimple)go/mysql/instance_key.gowith//nolint:gosimplebecause it's not a big dealS1011: should replace loop with env = append(env, extraVariables...) (gosimple)S1038: should use fmt.Fprintf instead of fmt.Fprintln(fmt.Sprintf(...)) (but don't forget the newline) (gosimple)composites: REDACTED composite literal uses unkeyed fields (govet)unreachable: unreachable code (govet)executeAndThrottleOnErrorfunc fromgo/logic/migrator.goscript/cibuildreturns with no formatting errors, build errors or unit test errors.