Skip to content

Commit

Permalink
Fix lint and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-asawicki committed Nov 23, 2023
1 parent bd33dd5 commit dd5e885
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ 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

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.)

Expand Down
5 changes: 2 additions & 3 deletions pkg/architest/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/architest/files.go
Original file line number Diff line number Diff line change
@@ -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)
}
Expand All @@ -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)
}
}
7 changes: 5 additions & 2 deletions pkg/architest/methods.go
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit dd5e885

Please sign in to comment.