Skip to content

Commit

Permalink
remove deprecated usage of varcheck, deadcode, and structcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Tantalor93 committed Sep 16, 2022
1 parent 72a2d89 commit 8e6ece9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 39 deletions.
4 changes: 1 addition & 3 deletions .golangci.yml
Expand Up @@ -3,11 +3,9 @@ run:
linters:
disable-all: true
enable:
- deadcode
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- varcheck
- whitespace
- unused
1 change: 1 addition & 0 deletions coremain/run.go
Expand Up @@ -170,6 +170,7 @@ var (

// Build information obtained with the help of -ldflags
var (
// nolint
appVersion = "(untracked dev build)" // inferred at startup
devBuild = true // inferred at startup

Expand Down
37 changes: 1 addition & 36 deletions test/presubmit_test.go
Expand Up @@ -125,7 +125,7 @@ func (l logfmt) Visit(n ast.Node) ast.Visitor {
if !ok {
return l
}
if id.Name != "t" { //t *testing.T
if id.Name != "t" { // t *testing.T
return l
}

Expand Down Expand Up @@ -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) {
walker := testImportOrderingWalker{}
err := filepath.Walk("..", walker.walk)
Expand Down

0 comments on commit 8e6ece9

Please sign in to comment.