fix(lint): noctx fixes and dead-code cleanup
- install_script_test.go: exec.Command -> exec.CommandContext (noctx) - architecture_test.go, store_test.go: go fix removed now-unused inspectEngineFamilies/parsePackageFiles/stringPtr helpers.
This commit is contained in:
1 parent
536e4bc0d1
commit
0fc20319c7
3 files changed
+6
-58
No files matched your search
@@ -4,7 +4,6 @@ import (
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"io/fs"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -164,58 +163,6 @@ type engineFamily struct {
|
||||
singleOwner bool
|
||||
}
|
||||
|
||||
func inspectEngineFamilies(root string) ([]engineFamily, error) {
|
||||
dirs := make(map[string]struct{})
|
||||
err := filepath.WalkDir(root, func(path string, entry fs.DirEntry, walkErr error) error {
|
||||
if walkErr != nil {
|
||||
return walkErr
|
||||
}
|
||||
if entry.IsDir() {
|
||||
dirs[path] = struct{}{}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var families []engineFamily
|
||||
for dir := range dirs {
|
||||
packages, err := parsePackageFiles(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, files := range packages {
|
||||
families = append(families, engineFamiliesInPackage(root, dir, files)...)
|
||||
}
|
||||
}
|
||||
slices.SortFunc(families, func(a, b engineFamily) int {
|
||||
return strings.Compare(a.packagePath+"."+a.engineName, b.packagePath+"."+b.engineName)
|
||||
})
|
||||
return families, nil
|
||||
}
|
||||
|
||||
func parsePackageFiles(dir string) (map[string][]*ast.File, error) {
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
packages := make(map[string][]*ast.File)
|
||||
fileSet := token.NewFileSet()
|
||||
for _, entry := range entries {
|
||||
if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".go") || strings.HasSuffix(entry.Name(), "_test.go") {
|
||||
continue
|
||||
}
|
||||
file, err := parser.ParseFile(fileSet, filepath.Join(dir, entry.Name()), nil, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
packages[file.Name.Name] = append(packages[file.Name.Name], file)
|
||||
}
|
||||
return packages, nil
|
||||
}
|
||||
|
||||
func engineFamiliesInPackage(root, dir string, files []*ast.File) []engineFamily {
|
||||
engines := make(map[string]bool)
|
||||
interfaces := make(map[string]*ast.InterfaceType)
|
||||
|
||||
Reference in new issue
Block a user