diff --git a/Makefile b/Makefile index 0b2a2fc7d9..48b0efe3a1 100644 --- a/Makefile +++ b/Makefile @@ -38,10 +38,10 @@ install: ## install the binary go install -v ./... lint: # Run static code analysis, check formatting. See https://golangci-lint.run/ - golangci-lint run ./... -v + ./bin/golangci-lint run ./... -v lint-fix: ## Run static code analysis, check formatting and try to fix findings - golangci-lint run ./... -v --fix + ./bin/golangci-lint run ./... -v --fix mod: ## add missing and remove unused modules go mod tidy -compat=1.20 @@ -49,7 +49,7 @@ mod: ## add missing and remove unused modules mod-check: mod ## check if there are any missing/unused modules git diff --exit-code -- go.mod go.sum -pre-push: fmt docs mod lint ## Run a few checks before pushing a change (docs, fmt, mod, etc.) +pre-push: fmt docs mod lint ## Run a few checks before pushing a change (docs, fmt, mod, etc.) pre-push-check: fmt-check docs-check lint-check mod-check ## Run a few checks before pushing a change (docs, fmt, mod, etc.) diff --git a/pkg/architest/file.go b/pkg/architest/file.go index 62f62d7941..a2d781a719 100644 --- a/pkg/architest/file.go +++ b/pkg/architest/file.go @@ -40,9 +40,8 @@ func (f *File) Name() string { func (f *File) ExportedMethods() Methods { allExportedMethods := make(Methods, 0) for _, d := range f.fileSrc.Decls { - switch d.(type) { - case *ast.FuncDecl: - name := d.(*ast.FuncDecl).Name.Name + if v, ok := d.(*ast.FuncDecl); ok { + name := v.Name.Name if ast.IsExported(name) { allExportedMethods = append(allExportedMethods, *NewMethod(name, f)) } diff --git a/pkg/architest/files.go b/pkg/architest/files.go index 4462d01485..6b73d2b039 100644 --- a/pkg/architest/files.go +++ b/pkg/architest/files.go @@ -1,12 +1,15 @@ package architest -type FileFilter = func(*File) bool -type FileReceiver = func(*File) -type Files []File +type ( + FileFilter = func(*File) bool + FileReceiver = func(*File) + Files []File +) func (files Files) Filter(filter FileFilter) Files { filteredFiles := make([]File, 0) for _, f := range files { + f := f if filter(&f) { filteredFiles = append(filteredFiles, f) } @@ -16,6 +19,7 @@ func (files Files) Filter(filter FileFilter) Files { func (files Files) All(receiver FileReceiver) { for _, file := range files { + file := file receiver(&file) } } diff --git a/pkg/architest/methods.go b/pkg/architest/methods.go index e737ae1d5b..b94f8a8d75 100644 --- a/pkg/architest/methods.go +++ b/pkg/architest/methods.go @@ -1,10 +1,13 @@ package architest -type MethodReceiver = func(method *Method) -type Methods []Method +type ( + MethodReceiver = func(method *Method) + Methods []Method +) func (methods Methods) All(receiver MethodReceiver) { for _, method := range methods { + method := method receiver(&method) } }