fix: fix a shadowing setting in .golangci.yml (#5654)

This commit is contained in:
Masaya Suzuki 2024-05-17 02:15:23 +09:00 committed by GitHub
parent 56576d491d
commit 03b4aa0798
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 43 deletions

View file

@ -1,41 +0,0 @@
---
#########################
#########################
## Golang Linter rules ##
#########################
#########################
# configure golangci-lint
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
issues:
exclude-rules:
- path: _test\.go
linters:
- dupl
- gosec
- goconst
linters:
enable:
- gosec
- unconvert
- gocyclo
- goconst
- goimports
- gocritic
- govet
- revive
linters-settings:
errcheck:
# report about assignment of errors to blank identifier
# default is false: such cases aren't reported by default.
check-blank: true
govet:
# report about shadowed variables
check-shadowing: true
gocyclo:
# minimal code complexity to report, 30 by default
min-complexity: 15
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true

View file

@ -30,8 +30,9 @@ linters-settings:
# default is false: such cases aren't reported by default. # default is false: such cases aren't reported by default.
check-blank: true check-blank: true
govet: govet:
# report about shadowed variables enable:
check-shadowing: true # report about shadowed variables
- shadowing
gocyclo: gocyclo:
# minimal code complexity to report, 30 by default # minimal code complexity to report, 30 by default
min-complexity: 15 min-complexity: 15

View file

@ -8,3 +8,11 @@ import (
if len(in) == 0 { if len(in) == 0 {
return "", fmt.Errorf("Input is empty") return "", fmt.Errorf("Input is empty")
} }
x := 0
{
var x int
x++
}
fmt.Println(x)