mirror of
https://github.com/coredns/coredns.git
synced 2025-10-29 01:04:15 -04:00
GO linting bump and removal of deprecated linters (#5624)
* bump golangci-lint with support of go 1.19 Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com> * remove deprecated usage of varcheck, deadcode, and structcheck Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com> Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
This commit is contained in:
9
.github/workflows/golangci-lint.yml
vendored
9
.github/workflows/golangci-lint.yml
vendored
@@ -10,8 +10,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: '1.19.0'
|
go-version: '1.19.0'
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
# See https://github.com/golangci/golangci-lint-action/issues/442#issuecomment-1203786890
|
- name: golangci-lint
|
||||||
- name: Install golangci-lint
|
uses: golangci/golangci-lint-action@v3.2.0
|
||||||
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.3
|
with:
|
||||||
- name: Run golangci-lint
|
version: v1.49.0
|
||||||
run: golangci-lint run --version --verbose --out-format=github-actions
|
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ run:
|
|||||||
linters:
|
linters:
|
||||||
disable-all: true
|
disable-all: true
|
||||||
enable:
|
enable:
|
||||||
- deadcode
|
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- structcheck
|
|
||||||
- typecheck
|
- typecheck
|
||||||
- varcheck
|
|
||||||
- whitespace
|
- whitespace
|
||||||
|
- unused
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ var (
|
|||||||
|
|
||||||
// Build information obtained with the help of -ldflags
|
// Build information obtained with the help of -ldflags
|
||||||
var (
|
var (
|
||||||
|
// nolint
|
||||||
appVersion = "(untracked dev build)" // inferred at startup
|
appVersion = "(untracked dev build)" // inferred at startup
|
||||||
devBuild = true // inferred at startup
|
devBuild = true // inferred at startup
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func (l logfmt) Visit(n ast.Node) ast.Visitor {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
if id.Name != "t" { //t *testing.T
|
if id.Name != "t" { // t *testing.T
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,41 +182,6 @@ func TestImportTesting(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type hasImportTestingWalker struct {
|
|
||||||
Errors []error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *hasImportTestingWalker) walk(path string, info os.FileInfo, _ error) error {
|
|
||||||
// only for regular files, not starting with a . and those that are go files.
|
|
||||||
if !info.Mode().IsRegular() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(path, "../.") {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if strings.Contains(path, "/vendor") {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if strings.HasSuffix(path, "_test.go") {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasSuffix(path, ".go") {
|
|
||||||
fs := token.NewFileSet()
|
|
||||||
f, err := parser.ParseFile(fs, path, nil, parser.AllErrors)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for _, im := range f.Imports {
|
|
||||||
if im.Path.Value == `"testing"` {
|
|
||||||
absPath, _ := filepath.Abs(path)
|
|
||||||
w.Errors = append(w.Errors, fmt.Errorf("file %q is importing %q", absPath, "testing"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestImportOrdering(t *testing.T) {
|
func TestImportOrdering(t *testing.T) {
|
||||||
walker := testImportOrderingWalker{}
|
walker := testImportOrderingWalker{}
|
||||||
err := filepath.Walk("..", walker.walk)
|
err := filepath.Walk("..", walker.walk)
|
||||||
|
|||||||
Reference in New Issue
Block a user