From 03b4aa0798b7e1e4b45d918d1577ca56f634a855 Mon Sep 17 00:00:00 2001 From: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Date: Fri, 17 May 2024 02:15:23 +0900 Subject: [PATCH] fix: fix a shadowing setting in .golangci.yml (#5654) --- .github/linters/.golangci.yml | 41 ------------------- TEMPLATES/.golangci.yml | 5 ++- .../go_modules_bad/golang_bad_01.go | 8 ++++ 3 files changed, 11 insertions(+), 43 deletions(-) delete mode 100644 .github/linters/.golangci.yml diff --git a/.github/linters/.golangci.yml b/.github/linters/.golangci.yml deleted file mode 100644 index d6daab0d..00000000 --- a/.github/linters/.golangci.yml +++ /dev/null @@ -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 diff --git a/TEMPLATES/.golangci.yml b/TEMPLATES/.golangci.yml index 67ae8b75..87e05037 100644 --- a/TEMPLATES/.golangci.yml +++ b/TEMPLATES/.golangci.yml @@ -30,8 +30,9 @@ linters-settings: # default is false: such cases aren't reported by default. check-blank: true govet: - # report about shadowed variables - check-shadowing: true + enable: + # report about shadowed variables + - shadowing gocyclo: # minimal code complexity to report, 30 by default min-complexity: 15 diff --git a/test/linters/go_modules/go_modules_bad/golang_bad_01.go b/test/linters/go_modules/go_modules_bad/golang_bad_01.go index 1a5ae1ad..e2487d09 100644 --- a/test/linters/go_modules/go_modules_bad/golang_bad_01.go +++ b/test/linters/go_modules/go_modules_bad/golang_bad_01.go @@ -8,3 +8,11 @@ import ( if len(in) == 0 { return "", fmt.Errorf("Input is empty") } + +x := 0 +{ + var x int + x++ +} + +fmt.Println(x)