-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(linter): fix golangci-lint warnings across substation (#32)
* fix(linter): fix golangci-lint warnings across substation * handle or explicitly ignore all errors * remove redundant function calls/conversions * rename predeclared `caps` identifier * tools: gofmt -> gofumpt, and staticcheck -> golangci-lint * fixup! fix(linter): fix golangci-lint warnings across substation Address code review comments. Changes include: - Undoing spurious whitespace changes - Rename variables with modifiers related to `cap` like newCap - Adding variable naming conventions to docs * docs: move first "Environment Variables" heading under "Design"
- Loading branch information
1 parent
d8df4e2
commit 9b7e077
Showing
112 changed files
with
1,562 additions
and
1,361 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# This code is licensed under the terms of the MIT license. | ||
|
||
## Config for golangci-lint v1.49.0 based on https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322 | ||
|
||
run: | ||
# Timeout for analysis, e.g. 30s, 5m. | ||
# Default: 1m | ||
timeout: 3m | ||
|
||
|
||
# This file contains only configs which differ from defaults. | ||
# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml | ||
linters-settings: | ||
cyclop: | ||
# The maximal code complexity to report. | ||
# Default: 10 | ||
max-complexity: 30 | ||
|
||
errcheck: | ||
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`. | ||
# Such cases aren't reported by default. | ||
# Default: false | ||
check-type-assertions: true | ||
|
||
gocognit: | ||
# Minimal code complexity to report | ||
# Default: 30 | ||
min-complexity: 45 | ||
|
||
# gomodguard: | ||
# blocked: | ||
# # List of blocked modules. | ||
# # Default: [] | ||
# modules: | ||
# - github.com/golang/protobuf: | ||
# recommendations: | ||
# - google.golang.org/protobuf | ||
# reason: "see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules" | ||
|
||
nakedret: | ||
# Make an issue if func has more lines of code than this setting, and it has naked returns. | ||
# Default: 30 | ||
max-func-lines: 0 | ||
|
||
nolintlint: | ||
# Exclude following linters from requiring an explanation. | ||
# Default: [] | ||
allow-no-explanation: [ gocognit ] | ||
# Enable to require an explanation of nonzero length after each nolint directive. | ||
# Default: false | ||
require-explanation: true | ||
# Enable to require nolint directives to mention the specific linter being suppressed. | ||
# Default: false | ||
require-specific: true | ||
|
||
rowserrcheck: | ||
# database/sql is always checked | ||
# Default: [] | ||
packages: | ||
- github.com/jmoiron/sqlx | ||
|
||
tenv: | ||
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures. | ||
# Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked. | ||
# Default: false | ||
all: true | ||
|
||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
## enabled by default | ||
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases | ||
- gosimple # specializes in simplifying a code | ||
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string | ||
- ineffassign # detects when assignments to existing variables are not used | ||
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks | ||
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code | ||
- unused # checks for unused constants, variables, functions and types | ||
|
||
## disabled by default | ||
- bidichk # checks for dangerous unicode character sequences | ||
- bodyclose # checks whether HTTP response body is closed successfully | ||
- cyclop # checks function and package cyclomatic complexity | ||
- durationcheck # checks for two durations multiplied together | ||
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error | ||
- execinquery # checks query string in Query function which reads your Go src files and warning it finds | ||
- exhaustive # checks exhaustiveness of enum switch statements | ||
- gocognit # computes and checks the cognitive complexity of functions | ||
- gocyclo # computes and checks the cyclomatic complexity of functions | ||
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod | ||
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations | ||
- goprintffuncname # checks that printf-like functions are named with f at the end | ||
- nakedret # finds naked returns in functions greater than a specified function length | ||
- nestif # reports deeply nested if statements | ||
- nilerr # finds the code that returns nil even if it checks that the error is not nil | ||
- noctx # finds sending http request without context.Context | ||
- nolintlint # reports ill-formed or insufficient nolint directives | ||
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL | ||
- predeclared # finds code that shadows one of Go's predeclared identifiers | ||
- reassign # checks that package variables are not reassigned | ||
- rowserrcheck # checks whether Err of rows is checked successfully | ||
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed | ||
- tenv # detects using os.Setenv instead of t.Setenv since Go1.17 | ||
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes | ||
- unconvert # removes unnecessary type conversions | ||
- unparam # reports unused function parameters | ||
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library | ||
- wastedassign # finds wasted assignment statements | ||
- whitespace # detects leading and trailing whitespace | ||
- misspell # finds commonly misspelled English words in comments | ||
|
||
issues: | ||
# Maximum count of issues with the same text. | ||
# Set to 0 to disable. | ||
# Default: 3 | ||
max-same-issues: 50 | ||
|
||
exclude: | ||
- 'declaration of "(err|ctx)" shadows declaration at' | ||
|
||
exclude-rules: | ||
- source: "^//\\s*go:generate\\s" | ||
linters: [ lll ] | ||
- source: "(noinspection|TODO)" | ||
linters: [ godot ] | ||
- source: "//noinspection" | ||
linters: [ gocritic ] | ||
- source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {" | ||
linters: [ errorlint ] | ||
- path: "_test\\.go" | ||
linters: | ||
- bodyclose | ||
- dupl | ||
- funlen | ||
- goconst | ||
- gosec | ||
- noctx | ||
- wrapcheck |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
{ | ||
"terminal.integrated.defaultProfile.linux": "bash", | ||
"go.formatTool": "gofmt", | ||
"go.useLanguageServer": true, | ||
"gopls": { | ||
"formatting.gofumpt": true, | ||
}, | ||
"go.formatTool": "gofumpt", | ||
"go.inferGopath": false, | ||
"go.lintFlags": ["-checks=all,-ST1000"], | ||
"go.lintOnSave": "workspace", | ||
"go.lintTool": "golangci-lint", | ||
"cSpell.enabled": false | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.