From bafb0991acd061a68202f0324d63f39fdb1b1ebe Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 18 Mar 2024 15:29:52 +0100 Subject: [PATCH] feat: add a constructor with configuration structure --- analyzer.go | 20 +++++++++++++------- linter/ginkgo_linter.go | 2 +- {internal/types => types}/boolean.go | 0 {internal/types => types}/boolean_test.go | 0 {internal/types => types}/config.go | 0 {internal/types => types}/config_test.go | 0 6 files changed, 14 insertions(+), 8 deletions(-) rename {internal/types => types}/boolean.go (100%) rename {internal/types => types}/boolean_test.go (100%) rename {internal/types => types}/config.go (100%) rename {internal/types => types}/config_test.go (100%) diff --git a/analyzer.go b/analyzer.go index 04c079b..edff57a 100644 --- a/analyzer.go +++ b/analyzer.go @@ -6,11 +6,22 @@ import ( "golang.org/x/tools/go/analysis" - "github.com/nunnatsa/ginkgolinter/internal/types" "github.com/nunnatsa/ginkgolinter/linter" + "github.com/nunnatsa/ginkgolinter/types" "github.com/nunnatsa/ginkgolinter/version" ) +// NewAnalyzerWithConfig returns an Analyzer. +func NewAnalyzerWithConfig(config *types.Config) *analysis.Analyzer { + theLinter := linter.NewGinkgoLinter(config) + + return &analysis.Analyzer{ + Name: "ginkgolinter", + Doc: fmt.Sprintf(doc, version.Version()), + Run: theLinter.Run, + } +} + // NewAnalyzer returns an Analyzer - the package interface with nogo func NewAnalyzer() *analysis.Analyzer { config := &types.Config{ @@ -23,12 +34,7 @@ func NewAnalyzer() *analysis.Analyzer { ForceExpectTo: false, } - theLinter := linter.NewGinkgoLinter(config) - a := &analysis.Analyzer{ - Name: "ginkgolinter", - Doc: fmt.Sprintf(doc, version.Version()), - Run: theLinter.Run, - } + a := NewAnalyzerWithConfig(config) var ignored bool a.Flags.Init("ginkgolinter", flag.ExitOnError) diff --git a/linter/ginkgo_linter.go b/linter/ginkgo_linter.go index c49cc41..b158c3a 100644 --- a/linter/ginkgo_linter.go +++ b/linter/ginkgo_linter.go @@ -19,7 +19,7 @@ import ( "github.com/nunnatsa/ginkgolinter/internal/intervals" "github.com/nunnatsa/ginkgolinter/internal/reports" "github.com/nunnatsa/ginkgolinter/internal/reverseassertion" - "github.com/nunnatsa/ginkgolinter/internal/types" + "github.com/nunnatsa/ginkgolinter/types" ) // The ginkgolinter enforces standards of using ginkgo and gomega. diff --git a/internal/types/boolean.go b/types/boolean.go similarity index 100% rename from internal/types/boolean.go rename to types/boolean.go diff --git a/internal/types/boolean_test.go b/types/boolean_test.go similarity index 100% rename from internal/types/boolean_test.go rename to types/boolean_test.go diff --git a/internal/types/config.go b/types/config.go similarity index 100% rename from internal/types/config.go rename to types/config.go diff --git a/internal/types/config_test.go b/types/config_test.go similarity index 100% rename from internal/types/config_test.go rename to types/config_test.go