-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It would be nice to have some linting beyond `go vet`! Now we do. I started by copying the config from Khan/webapp. I did remove a couple of staticcheck checks that I didn't feel were useful. (Note also that exportloopref is the replacement for scopelint in newer golangci-lint.) Included are all the needed lint fixes; most are stylistic but the changes in the example are a (minor) bugfix. Fixes #22. Issue: #22 Test plan: make check
- Loading branch information
1 parent
dfc9f02
commit 6cc0e26
Showing
12 changed files
with
136 additions
and
21 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,101 @@ | ||
# For the full list of configuration options, see | ||
# https://github.com/golangci/golangci-lint#config-file | ||
|
||
# See more about these linters at https://golangci-lint.run/usage/linters/ | ||
linters: | ||
fast: false | ||
disable-all: true | ||
enable: | ||
# golangci enables these by default. | ||
- deadcode | ||
- errcheck | ||
- gofumpt # (replaces gofmt) | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- structcheck | ||
- typecheck | ||
- unused | ||
- varcheck | ||
# golangci disables these by default, but we use them. | ||
- bodyclose | ||
- depguard | ||
- durationcheck | ||
- errorlint | ||
- exportloopref | ||
- gocritic | ||
- nakedret | ||
- stylecheck | ||
- unconvert | ||
- unparam | ||
- whitespace | ||
|
||
linters-settings: | ||
errcheck: | ||
check-type-assertions: true # check for a := b.(T) | ||
|
||
errorlint: | ||
errorf: false # it's valid to use %v instead of %w | ||
|
||
govet: | ||
check-shadowing: true | ||
enable-all: true | ||
|
||
# We have a ton of test-only packages; but make sure we keep prod deps small. | ||
depguard: | ||
list-type: whitelist | ||
packages: | ||
- github.com/Khan/genqlient | ||
- github.com/vektah/gqlparser/v2 | ||
- golang.org/x/tools | ||
- gopkg.in/yaml.v2 | ||
|
||
gocritic: | ||
# Which checks should be enabled: | ||
# See https://go-critic.github.io/overview#checks-overview | ||
# and https://github.com/go-critic/go-critic#usage -> section "Tags". | ||
# To check which checks are enabled: `GL_DEBUG=gocritic golangci-lint run` | ||
enabled-tags: | ||
- diagnostic | ||
- performance | ||
- style | ||
|
||
disabled-checks: | ||
- builtinShadow | ||
- commentedOutCode | ||
- importShadow | ||
- paramTypeCombine | ||
- unnamedResult | ||
- ifElseChain | ||
- sloppyReassign | ||
|
||
settings: # settings passed to gocritic | ||
captLocal: # must be valid enabled check name | ||
paramsOnly: true | ||
|
||
|
||
issues: | ||
exclude-rules: | ||
# Test-only deps are not restricted. | ||
- linters: | ||
- depguard | ||
path: _test\.go$|internal/testutil/ | ||
|
||
- linters: | ||
- errcheck | ||
path: _test\.go$ | ||
# Unchecked type-asserts are ok in tests -- a panic will be plenty clear. | ||
# An error message with no function name means an unchecked type-assert. | ||
text: "^Error return value is not checked$" | ||
|
||
# Don't error if a test setup function always takes the same arguments. | ||
- linters: | ||
- unparam | ||
path: _test\.go$ | ||
|
||
- linters: | ||
- govet | ||
# Only a big deal for runtime code. | ||
path: ^generate/|^example/ | ||
text: "^fieldalignment: struct with \\d+ pointer bytes could be \\d+$" |
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
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
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