Skip to content

Commit

Permalink
chore: Lint fixes for variable shadowing (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmichaelchen authored Jun 21, 2023
1 parent 9ed8ada commit 3492274
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 112 deletions.
191 changes: 82 additions & 109 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ output:
path-prefix: ""
# all available settings of specific linters
linters-settings:
ireturn:
# ireturn does not allow using `allow` and `reject` settings at the same time.
# Both settings are lists of the keywords and regular expressions matched to interface or package names.
# keywords:
# - `empty` for `interface{}`
# - `error` for errors
# - `stdlib` for standard library
# - `anon` for anonymous interfaces
# - `generic` for generic interfaces added in go 1.18

# By default, it allows using errors, empty interfaces, anonymous interfaces,
# and interfaces provided by the standard library.
allow:
- anon
- error
- empty
- stdlib
# You can specify idiomatic endings for interface
- (or|er)$
- go.uber.org/fx.Option
- go.temporal.io/sdk/client.Client
varnamelen:
# The longest distance, in source lines, that is being considered a "small scope".
# Variables used in at most this many lines will be ignored.
Expand Down Expand Up @@ -111,27 +132,42 @@ linters-settings:
- T any
- m map[string]int
- ok bool
ireturn:
# ireturn does not allow using `allow` and `reject` settings at the same time.
# Both settings are lists of the keywords and regular expressions matched to interface or package names.
# keywords:
# - `empty` for `interface{}`
# - `error` for errors
# - `stdlib` for standard library
# - `anon` for anonymous interfaces
# - `generic` for generic interfaces added in go 1.18

# By default, it allows using errors, empty interfaces, anonymous interfaces,
# and interfaces provided by the standard library.
allow:
- anon
- error
- empty
- stdlib
# You can specify idiomatic endings for interface
- (or|er)$
- go.uber.org/fx.Option
- go.temporal.io/sdk/client.Client
govet:
# Report about shadowed variables.
# Default: false
check-shadowing: true
# Settings per analyzer.
settings:
# Analyzer name, run `go tool vet help` to see all analyzers.
printf:
# Comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`).
# Default: []
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
shadow:
# Whether to be strict about shadowing; can be noisy.
# Default: false
strict: true
unusedresult:
# Comma-separated list of functions whose results must be used
# (in addition to defaults context.WithCancel,context.WithDeadline,context.WithTimeout,context.WithValue,
# errors.New,fmt.Errorf,fmt.Sprint,fmt.Sprintf,sort.Reverse)
# Default []
funcs:
- pkg.MyFunc
# Comma-separated list of names of methods of type func() string whose results must be used
# (in addition to default Error,String)
# Default []
stringmethods:
- MyMethod
# Enable all analyzers.
# Default: false
enable-all: true
disable:
- fieldalignment
wrapcheck:
# An array of strings that specify substrings of signatures to ignore.
# If this set, it will override the default set of ignored signatures.
Expand Down Expand Up @@ -234,6 +270,12 @@ linters-settings:
funlen:
lines: 80
statements: 40

# gci:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
# local-prefixes: github.com/kevinmichaelchen/temporal-saga-grpc
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
Expand Down Expand Up @@ -446,94 +488,25 @@ gofumpt:
# Intended to point to the repo location of the linter. Optional, just for documentation purposes.
# original-url: github.com/golangci/example-linter
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- cyclop
- decorder
# - depguard
- dogsled
- dupl
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
# - errorlint
- exhaustive
# - exhaustruct
- exportloopref
- forbidigo
- funlen
- gci
- gocheckcompilerdirectives
# - gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
# - godox
- goerr113
- gofmt
- gofumpt
- goheader
- goimports
- gomoddirectives
- govet
- goprintffuncname
- gosec
- gosmopolitan
- gosimple
- govet
- importas
- interfacebloat
- ireturn
- ineffassign
- loggercheck
- lll
- maintidx
- misspell
- musttag
- nakedret
- nestif
- noctx
- nolintlint
- nilerr
- nilnil
- nlreturn
- noctx
- nonamedreturns
- nosprintfhostport
- paralleltest
- predeclared
- reassign
- rowserrcheck
- revive
- sqlclosecheck
- staticcheck
- exportloopref
- tagalign
- tagliatelle
- tenv
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- usestdlibvars
- unused
- varnamelen
- wastedassign
- whitespace
- wrapcheck
- wsl
enable-all: true
disable:
- deadcode
- depguard # TEMPORARY
- errorlint # TEMPORARY
- exhaustruct
- exhaustivestruct
- gochecknoglobals
- godox
- golint
- gomnd
- ifshort
- interfacer
- maligned
- nosnakecase
- scopelint
- structcheck
- testpackage
- varcheck
issues:
# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
Expand Down
2 changes: 1 addition & 1 deletion cmd/saga/start/service/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestValidate(t *testing.T) {
t.Run(testName, func(t *testing.T) {
t.Parallel()

err := validate(validator, tc.build())
err = validate(validator, tc.build())
tc.expect(t, err)
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/connect/pgv/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Convert(err error) error {
pgves, ok := err.(MultiError)
if ok {
for _, p := range pgves.AllErrors() {
pgve, ok := p.(Error)
pgve, ok = p.(Error)
if ok {
fieldViolations = append(fieldViolations, &errdetails.BadRequest_FieldViolation{
Field: pgve.Field(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/fxmod/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func NewTracerProvider(lifecycle fx.Lifecycle, opts *ModuleOptions, cfg *Config)

log.Println("Shutting down TracerProvider...")

err := tracerProvider.Shutdown(ctx)
err = tracerProvider.Shutdown(ctx)
if err != nil {
return fmt.Errorf("unable to shut down tracer provider: %w", err)
}
Expand Down

0 comments on commit 3492274

Please sign in to comment.