From 626a8afe169f57b4b128fe111808ac932b0daca2 Mon Sep 17 00:00:00 2001 From: Anton Telyshev Date: Thu, 7 Dec 2023 08:37:09 +0200 Subject: [PATCH 1/3] cosmetic fixes --- .golangci.yml | 3 ++- Makefile | 13 ++++++++++++ README.md | 10 +++++---- factory.go | 54 +++++++++++++------------------------------------ lint_test.go | 23 +++++++++------------ strings_flag.go | 25 +++++++++++++++++++++++ 6 files changed, 70 insertions(+), 58 deletions(-) create mode 100644 strings_flag.go diff --git a/.golangci.yml b/.golangci.yml index 38a2c4a..67e785f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -36,6 +36,7 @@ issues: - path: lint_test linters: - varnamelen + - wrapcheck - linters: - lll source: "^(?: |\t)*// " @@ -45,4 +46,4 @@ issues: - linters: - godot - lll - source: "// ?TODO " \ No newline at end of file + source: "// ?TODO " diff --git a/Makefile b/Makefile index 330e555..9f5e788 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,17 @@ +.PHONY: fmt lint clean.test test test.clean + CVPKG=go list ./... | grep -v mocks | grep -v internal/ GO_TEST=go test `$(CVPKG)` -race COVERAGE_FILE="coverage.out" +all: fmt lint test install + +fmt: + go fmt ./... + +lint: + golangci-lint run --fix ./... + clean.test: go clean --testcache @@ -12,3 +22,6 @@ test.clean: clean.test test test.coverage: $(GO_TEST) -covermode=atomic -coverprofile=$(COVERAGE_FILE) + +install: + go install ./cmd/go-factory-lint diff --git a/README.md b/README.md index 3d1cfb3..c414e95 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,18 @@ The linter checks that the Structures are created by the Factory, and not direct The checking helps to provide invariants without exclusion and helps avoid creating an invalid object. -## Use +## Usage -Installation +### Installation go install github.com/maranqz/go-factory-lint/cmd/go-factory-lint@latest ### Options -- `--packageGlobs` - list of glob packages, which can create structures without factories inside the glob package. By default, all structures from another package should be created by factories, [tests](testdata/src/factory/packageGlobs). - - `onlyPackageGlobs` - use a factory to initiate a structure for glob packages only, [tests](testdata/src/factory/onlyPackageGlobs). +- `--packageGlobs` – list of glob packages, which can create structures without factories inside the glob package. +By default, all structures from another package should be created by factories, [tests](testdata/src/factory/packageGlobs). +- `--onlyPackageGlobs` – use a factory to initiate a structure for glob packages only, +[tests](testdata/src/factory/onlyPackageGlobs). Doesn't make sense without `--packageGlobs`. ## Example diff --git a/factory.go b/factory.go index 07faa0a..d8d88cd 100644 --- a/factory.go +++ b/factory.go @@ -5,11 +5,9 @@ import ( "go/ast" "go/types" "log" - "strings" "github.com/gobwas/glob" "golang.org/x/tools/go/analysis" - "golang.org/x/tools/go/analysis/passes/inspect" ) type config struct { @@ -17,38 +15,18 @@ type config struct { onlyPkgGlobs bool } -type stringsFlag []string - -func (s stringsFlag) String() string { - return strings.Join(s, ", ") -} - -func (s *stringsFlag) Set(value string) error { - *s = append(*s, value) - - return nil -} - -func (s stringsFlag) Value() []string { - res := make([]string, 0, len(s)) - - for _, str := range s { - res = append(res, strings.TrimSpace(str)) - } - - return res -} - const ( - packageGlobsDesc = "List of glob packages, which can create structures without factories inside the glob package" - onlyPkgGlobsDesc = "Use a factory to initiate a structure for glob packages only." + name = "gofactory" + doc = "Blocks the creation of structures directly, without a factory." + + packageGlobsDesc = "list of glob packages, which can create structures without factories inside the glob package" + onlyPkgGlobsDesc = "use a factory to initiate a structure for glob packages only" ) func NewAnalyzer() *analysis.Analyzer { analyzer := &analysis.Analyzer{ - Name: "gofactory", - Doc: "Blocks the creation of structures directly, without a factory.", - Requires: []*analysis.Analyzer{inspect.Analyzer}, + Name: name, + Doc: doc, } cfg := config{} @@ -231,18 +209,14 @@ func (v *visitor) checkBrackets(expr ast.Expr, identObj types.Object) { func (v *visitor) report(node ast.Node, obj types.Object) { v.pass.Reportf( node.Pos(), - fmt.Sprintf(`Use factory for %s.%s`, obj.Pkg().Name(), obj.Name()), + "Use factory for %s.%s", obj.Pkg().Name(), obj.Name(), ) } func (v *visitor) unexpectedCode(node ast.Node) { - fset := v.pass.Fset - pos := fset.Position(node.Pos()) - - log.Printf("Unexpected code in %s:%d:%d, please report to the developer with example.\n", - fset.File(node.Pos()).Name(), - pos.Line, - pos.Column, + log.Printf("%s: unexpected code in %s, please report to the developer with example.\n", + name, + v.pass.Fset.Position(node.Pos()), ) } @@ -260,12 +234,12 @@ func compileGlobs(globs []string) ([]glob.Glob, error) { compiledGlobs := make([]glob.Glob, len(globs)) for idx, globString := range globs { - glob, err := glob.Compile(globString) + compiled, err := glob.Compile(globString) if err != nil { - return nil, fmt.Errorf("unable to compile globs %s: %w", glob, err) + return nil, fmt.Errorf("unable to compile glob %q: %w", globString, err) } - compiledGlobs[idx] = glob + compiledGlobs[idx] = compiled } return compiledGlobs, nil diff --git a/lint_test.go b/lint_test.go index a83579e..b60a26c 100644 --- a/lint_test.go +++ b/lint_test.go @@ -17,29 +17,25 @@ func TestLinterSuite(t *testing.T) { tests := map[string]struct { pkgs []string - prepare func(t *testing.T, a *analysis.Analyzer) + prepare func(t *testing.T, a *analysis.Analyzer) error }{ "simple": {pkgs: []string{"simple/..."}}, "casting": {pkgs: []string{"casting/..."}}, "generic": {pkgs: []string{"generic/..."}}, "packageGlobs": { pkgs: []string{"packageGlobs/..."}, - prepare: func(t *testing.T, a *analysis.Analyzer) { - if err := a.Flags.Set("packageGlobs", "factory/packageGlobs/blocked/**"); err != nil { - t.Fatal(err) - } + prepare: func(t *testing.T, a *analysis.Analyzer) error { + return a.Flags.Set("packageGlobs", "factory/packageGlobs/blocked/**") }, }, "onlyPackageGlobs": { pkgs: []string{"onlyPackageGlobs/main/..."}, - prepare: func(t *testing.T, a *analysis.Analyzer) { + prepare: func(t *testing.T, a *analysis.Analyzer) error { if err := a.Flags.Set("packageGlobs", "factory/onlyPackageGlobs/blocked/**"); err != nil { - t.Fatal(err) + return err } - if err := a.Flags.Set("onlyPackageGlobs", "true"); err != nil { - t.Fatal(err) - } + return a.Flags.Set("onlyPackageGlobs", "true") }, }, } @@ -58,11 +54,12 @@ func TestLinterSuite(t *testing.T) { analyzer := factory.NewAnalyzer() if tt.prepare != nil { - tt.prepare(t, analyzer) + if err := tt.prepare(t, analyzer); err != nil { + t.Fatal(err) + } } - analysistest.Run(t, testdata, - analyzer, dirs...) + analysistest.Run(t, testdata, analyzer, dirs...) }) } } diff --git a/strings_flag.go b/strings_flag.go new file mode 100644 index 0000000..583f039 --- /dev/null +++ b/strings_flag.go @@ -0,0 +1,25 @@ +package factory + +import "strings" + +type stringsFlag []string + +func (s stringsFlag) String() string { + return strings.Join(s, ", ") +} + +func (s *stringsFlag) Set(value string) error { + *s = append(*s, value) + + return nil +} + +func (s stringsFlag) Value() []string { + res := make([]string, 0, len(s)) + + for _, str := range s { + res = append(res, strings.TrimSpace(str)) + } + + return res +} From 8c9d73e7798100b4451575dd0e0d8e79bf77d78b Mon Sep 17 00:00:00 2001 From: Ilia Sergunin Date: Fri, 15 Dec 2023 07:15:17 +0400 Subject: [PATCH 2/3] 1. renamed linter 2. stringsFlag replaced with globsFlag 3. onlyPackageGlobs renamed to packageGlobsOnly --- .github/workflows/release.yml | 4 +-- .golangci.yml | 2 +- Makefile | 2 +- README.md | 17 ++++----- cmd/{go-factory-lint => gofactory}/main.go | 4 +-- factory.go | 31 ++++------------ globs_flag.go | 35 +++++++++++++++++++ go.mod | 2 +- lint_test.go | 14 ++++---- strategy.go | 2 +- strings_flag.go | 25 ------------- .../src/factory/packageGlobs/nested/nested.go | 2 +- .../blocked/blocked.go | 2 +- .../blocked/blocked_nested/blocked_nested.go | 0 .../main/main.go | 6 ++-- .../nested/nested.go | 2 +- 16 files changed, 71 insertions(+), 79 deletions(-) rename cmd/{go-factory-lint => gofactory}/main.go (52%) create mode 100644 globs_flag.go delete mode 100644 strings_flag.go rename testdata/src/factory/{onlyPackageGlobs => packageGlobsOnly}/blocked/blocked.go (83%) rename testdata/src/factory/{onlyPackageGlobs => packageGlobsOnly}/blocked/blocked_nested/blocked_nested.go (100%) rename testdata/src/factory/{onlyPackageGlobs => packageGlobsOnly}/main/main.go (89%) rename testdata/src/factory/{onlyPackageGlobs => packageGlobsOnly}/nested/nested.go (91%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b225e27..45af428 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - v* env: - GO_VERSION: "1.21" + GO_VERSION: "1.20" jobs: @@ -36,6 +36,6 @@ jobs: with: version: latest args: release --clean - workdir: cmd/go-factory-lint/ + workdir: cmd/go-gofactory-lint/ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 67e785f..edfdfb9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -8,7 +8,7 @@ linters-settings: - v - ok gci: - local-prefixes: github.com/maranqz/go-factory-lint + local-prefixes: github.com/maranqz/gofactory linters: enable-all: true diff --git a/Makefile b/Makefile index 9f5e788..ec722a8 100644 --- a/Makefile +++ b/Makefile @@ -24,4 +24,4 @@ test.coverage: $(GO_TEST) -covermode=atomic -coverprofile=$(COVERAGE_FILE) install: - go install ./cmd/go-factory-lint + go install ./cmd/gofactory diff --git a/README.md b/README.md index c414e95..027b5e2 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Factory linter -[![CI](https://github.com/maranqz/go-factory-lint/actions/workflows/ci.yml/badge.svg)](https://github.com/maranqz/go-factory-lint/actions/workflows/ci.yml) -[![Go Report Card](https://goreportcard.com/badge/github.com/maranqz/go-factory-lint)](https://goreportcard.com/report/github.com/maranqz/go-factory-lint?dummy=unused) +[![CI](https://github.com/maranqz/gofactory/actions/workflows/ci.yml/badge.svg)](https://github.com/maranqz/gofactory/actions/workflows/ci.yml) +[![Go Report Card](https://goreportcard.com/badge/github.com/maranqz/gofactory)](https://goreportcard.com/report/github.com/maranqz/gofactory?dummy=unused) [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) -[![Coverage Status](https://coveralls.io/repos/github/maranqz/go-factory-lint/badge.svg?branch=main)](https://coveralls.io/github/maranqz/go-factory-lint?branch=main) +[![Coverage Status](https://coveralls.io/repos/github/maranqz/gofactory/badge.svg?branch=main)](https://coveralls.io/github/maranqz/gofactory?branch=main) The linter checks that the Structures are created by the Factory, and not directly. @@ -14,14 +14,14 @@ The checking helps to provide invariants without exclusion and helps avoid creat ### Installation - go install github.com/maranqz/go-factory-lint/cmd/go-factory-lint@latest + go install github.com/maranqz/gofactory/cmd/gofactory@latest ### Options - `--packageGlobs` – list of glob packages, which can create structures without factories inside the glob package. By default, all structures from another package should be created by factories, [tests](testdata/src/factory/packageGlobs). -- `--onlyPackageGlobs` – use a factory to initiate a structure for glob packages only, -[tests](testdata/src/factory/onlyPackageGlobs). Doesn't make sense without `--packageGlobs`. +- `--packageGlobsOnly` – use a factory to initiate a structure for glob packages only, +[tests](testdata/src/factory/packageGlobsOnly). Doesn't make sense without `--packageGlobs`. ## Example @@ -40,7 +40,7 @@ import ( ) func main() { - // Use factory for bad.User + // Use gofactory for bad.User u := &bad.User{ ID: -1, } @@ -130,6 +130,7 @@ Linter doesn't catch some cases. 2. Local initialization, [example](testdata/src/factory/unimplemented/local/). 3. Named return. If you want to block that case, you can use [nonamedreturns](https://github.com/firefart/nonamedreturns) linter, [example](testdata/src/factory/unimplemented/named_return.go). 4. var declaration, `var initilized nested.Struct` gives structure without factory, [example](testdata/src/factory/unimplemented/var.go). + To block that case, you can use [gopublicfield](github.com/maranqz/gopublicfield) to prevent fill of structure fields. ## TODO @@ -138,7 +139,7 @@ Linter doesn't catch some cases. 1. Catch nested struct in the same package, [example](testdata/src/factory/unimplemented/local/nested_struct.go). ```go return Struct{ - Other: OtherStruct{}, // want `Use factory for nested.Struct` + Other: OtherStruct{}, // want `Use gofactory for nested.Struct` } ``` 2. Resolve false negative issue with `var declaration`. diff --git a/cmd/go-factory-lint/main.go b/cmd/gofactory/main.go similarity index 52% rename from cmd/go-factory-lint/main.go rename to cmd/gofactory/main.go index 02af132..81bf9f3 100644 --- a/cmd/go-factory-lint/main.go +++ b/cmd/gofactory/main.go @@ -3,9 +3,9 @@ package main import ( "golang.org/x/tools/go/analysis/singlechecker" - "github.com/maranqz/go-factory-lint/v2" + "github.com/maranqz/gofactory" ) func main() { - singlechecker.Main(factory.NewAnalyzer()) + singlechecker.Main(gofactory.NewAnalyzer()) } diff --git a/factory.go b/factory.go index d8d88cd..45a9df6 100644 --- a/factory.go +++ b/factory.go @@ -1,7 +1,6 @@ -package factory +package gofactory import ( - "fmt" "go/ast" "go/types" "log" @@ -11,7 +10,7 @@ import ( ) type config struct { - pkgGlobs stringsFlag + pkgGlobs globsFlag onlyPkgGlobs bool } @@ -33,7 +32,7 @@ func NewAnalyzer() *analysis.Analyzer { analyzer.Flags.Var(&cfg.pkgGlobs, "packageGlobs", packageGlobsDesc) - analyzer.Flags.BoolVar(&cfg.onlyPkgGlobs, "onlyPackageGlobs", false, onlyPkgGlobsDesc) + analyzer.Flags.BoolVar(&cfg.onlyPkgGlobs, "packageGlobsOnly", false, onlyPkgGlobsDesc) analyzer.Run = run(&cfg) @@ -43,17 +42,14 @@ func NewAnalyzer() *analysis.Analyzer { func run(cfg *config) func(pass *analysis.Pass) (interface{}, error) { return func(pass *analysis.Pass) (interface{}, error) { var blockedStrategy blockedStrategy = newAnotherPkg() - if len(cfg.pkgGlobs) > 0 { + + pkgGlobs := cfg.pkgGlobs.Value() + if len(pkgGlobs) > 0 { defaultStrategy := blockedStrategy if cfg.onlyPkgGlobs { defaultStrategy = newNilPkg() } - pkgGlobs, err := compileGlobs(cfg.pkgGlobs.Value()) - if err != nil { - return nil, err - } - blockedStrategy = newBlockedPkgs( pkgGlobs, defaultStrategy, @@ -229,18 +225,3 @@ func containsMatchGlob(globs []glob.Glob, el string) bool { return false } - -func compileGlobs(globs []string) ([]glob.Glob, error) { - compiledGlobs := make([]glob.Glob, len(globs)) - - for idx, globString := range globs { - compiled, err := glob.Compile(globString) - if err != nil { - return nil, fmt.Errorf("unable to compile glob %q: %w", globString, err) - } - - compiledGlobs[idx] = compiled - } - - return compiledGlobs, nil -} diff --git a/globs_flag.go b/globs_flag.go new file mode 100644 index 0000000..fa7816a --- /dev/null +++ b/globs_flag.go @@ -0,0 +1,35 @@ +package gofactory + +import ( + "fmt" + "strings" + + "github.com/gobwas/glob" +) + +type globsFlag struct { + globsString []string + globs []glob.Glob +} + +func (g globsFlag) String() string { + return strings.Join(g.globsString, ", ") +} + +func (g *globsFlag) Set(globString string) error { + globString = strings.TrimSpace(globString) + + compiled, err := glob.Compile(globString) + if err != nil { + return fmt.Errorf("unable to compile globs %s: %w", globString, err) + } + + g.globsString = append(g.globsString, globString) + g.globs = append(g.globs, compiled) + + return nil +} + +func (g globsFlag) Value() []glob.Glob { + return g.globs +} diff --git a/go.mod b/go.mod index d51ed42..f388dbf 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/maranqz/go-factory-lint/v2 +module github.com/maranqz/gofactory go 1.20 diff --git a/lint_test.go b/lint_test.go index b60a26c..4631554 100644 --- a/lint_test.go +++ b/lint_test.go @@ -1,4 +1,4 @@ -package factory_test +package gofactory_test import ( "path/filepath" @@ -7,7 +7,7 @@ import ( "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/analysistest" - "github.com/maranqz/go-factory-lint/v2" + "github.com/maranqz/gofactory" ) func TestLinterSuite(t *testing.T) { @@ -28,14 +28,14 @@ func TestLinterSuite(t *testing.T) { return a.Flags.Set("packageGlobs", "factory/packageGlobs/blocked/**") }, }, - "onlyPackageGlobs": { - pkgs: []string{"onlyPackageGlobs/main/..."}, + "packageGlobsOnly": { + pkgs: []string{"packageGlobsOnly/main/..."}, prepare: func(t *testing.T, a *analysis.Analyzer) error { - if err := a.Flags.Set("packageGlobs", "factory/onlyPackageGlobs/blocked/**"); err != nil { + if err := a.Flags.Set("packageGlobs", "factory/packageGlobsOnly/blocked/**"); err != nil { return err } - return a.Flags.Set("onlyPackageGlobs", "true") + return a.Flags.Set("packageGlobsOnly", "true") }, }, } @@ -51,7 +51,7 @@ func TestLinterSuite(t *testing.T) { dirs = append(dirs, filepath.Join(testdata, "src", "factory", pkg)) } - analyzer := factory.NewAnalyzer() + analyzer := gofactory.NewAnalyzer() if tt.prepare != nil { if err := tt.prepare(t, analyzer); err != nil { diff --git a/strategy.go b/strategy.go index 9ab3436..0eb7a29 100644 --- a/strategy.go +++ b/strategy.go @@ -1,4 +1,4 @@ -package factory +package gofactory import ( "go/types" diff --git a/strings_flag.go b/strings_flag.go deleted file mode 100644 index 583f039..0000000 --- a/strings_flag.go +++ /dev/null @@ -1,25 +0,0 @@ -package factory - -import "strings" - -type stringsFlag []string - -func (s stringsFlag) String() string { - return strings.Join(s, ", ") -} - -func (s *stringsFlag) Set(value string) error { - *s = append(*s, value) - - return nil -} - -func (s stringsFlag) Value() []string { - res := make([]string, 0, len(s)) - - for _, str := range s { - res = append(res, strings.TrimSpace(str)) - } - - return res -} diff --git a/testdata/src/factory/packageGlobs/nested/nested.go b/testdata/src/factory/packageGlobs/nested/nested.go index a7f35b2..c9eda1c 100644 --- a/testdata/src/factory/packageGlobs/nested/nested.go +++ b/testdata/src/factory/packageGlobs/nested/nested.go @@ -1,7 +1,7 @@ package nested import ( - "factory/onlyPackageGlobs/blocked" + "factory/packageGlobsOnly/blocked" ) type Struct struct{} diff --git a/testdata/src/factory/onlyPackageGlobs/blocked/blocked.go b/testdata/src/factory/packageGlobsOnly/blocked/blocked.go similarity index 83% rename from testdata/src/factory/onlyPackageGlobs/blocked/blocked.go rename to testdata/src/factory/packageGlobsOnly/blocked/blocked.go index 693d2e4..9ce639a 100644 --- a/testdata/src/factory/onlyPackageGlobs/blocked/blocked.go +++ b/testdata/src/factory/packageGlobsOnly/blocked/blocked.go @@ -1,7 +1,7 @@ package blocked import ( - "factory/onlyPackageGlobs/blocked/blocked_nested" + "factory/packageGlobsOnly/blocked/blocked_nested" ) type Struct struct{} diff --git a/testdata/src/factory/onlyPackageGlobs/blocked/blocked_nested/blocked_nested.go b/testdata/src/factory/packageGlobsOnly/blocked/blocked_nested/blocked_nested.go similarity index 100% rename from testdata/src/factory/onlyPackageGlobs/blocked/blocked_nested/blocked_nested.go rename to testdata/src/factory/packageGlobsOnly/blocked/blocked_nested/blocked_nested.go diff --git a/testdata/src/factory/onlyPackageGlobs/main/main.go b/testdata/src/factory/packageGlobsOnly/main/main.go similarity index 89% rename from testdata/src/factory/onlyPackageGlobs/main/main.go rename to testdata/src/factory/packageGlobsOnly/main/main.go index ee5a225..36155f0 100644 --- a/testdata/src/factory/onlyPackageGlobs/main/main.go +++ b/testdata/src/factory/packageGlobsOnly/main/main.go @@ -1,9 +1,9 @@ package main import ( - "factory/onlyPackageGlobs/blocked" - "factory/onlyPackageGlobs/blocked/blocked_nested" - "factory/onlyPackageGlobs/nested" + "factory/packageGlobsOnly/blocked" + "factory/packageGlobsOnly/blocked/blocked_nested" + "factory/packageGlobsOnly/nested" ) type Struct struct{} diff --git a/testdata/src/factory/onlyPackageGlobs/nested/nested.go b/testdata/src/factory/packageGlobsOnly/nested/nested.go similarity index 91% rename from testdata/src/factory/onlyPackageGlobs/nested/nested.go rename to testdata/src/factory/packageGlobsOnly/nested/nested.go index ae66404..55e0a68 100644 --- a/testdata/src/factory/onlyPackageGlobs/nested/nested.go +++ b/testdata/src/factory/packageGlobsOnly/nested/nested.go @@ -1,7 +1,7 @@ package nested import ( - "factory/onlyPackageGlobs/blocked" + "factory/packageGlobsOnly/blocked" ) type Struct struct{} From 3c0b13288ca66f159b6e3d47030b0ff3b087009e Mon Sep 17 00:00:00 2001 From: Ilia Sergunin Date: Fri, 15 Dec 2023 07:17:38 +0400 Subject: [PATCH 3/3] 1. removed incorrect auto replacement --- .github/workflows/release.yml | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45af428..8ca34c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,6 +36,6 @@ jobs: with: version: latest args: release --clean - workdir: cmd/go-gofactory-lint/ + workdir: cmd/gofactory/ env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 027b5e2..70d5d33 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ import ( ) func main() { - // Use gofactory for bad.User + // Use factory for bad.User u := &bad.User{ ID: -1, } @@ -139,7 +139,7 @@ Linter doesn't catch some cases. 1. Catch nested struct in the same package, [example](testdata/src/factory/unimplemented/local/nested_struct.go). ```go return Struct{ - Other: OtherStruct{}, // want `Use gofactory for nested.Struct` + Other: OtherStruct{}, // want `Use factory for nested.Struct` } ``` 2. Resolve false negative issue with `var declaration`.