-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
small refactoring, to split big file a bit
- Loading branch information
Showing
3 changed files
with
57 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package ginkgolinter | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
|
||
"golang.org/x/tools/go/analysis" | ||
|
||
"github.com/nunnatsa/ginkgolinter/linter" | ||
"github.com/nunnatsa/ginkgolinter/types" | ||
"github.com/nunnatsa/ginkgolinter/version" | ||
) | ||
|
||
// NewAnalyzer returns an Analyzer - the package interface with nogo | ||
func NewAnalyzer() *analysis.Analyzer { | ||
config := &types.Config{ | ||
SuppressLen: false, | ||
SuppressNil: false, | ||
SuppressErr: false, | ||
SuppressCompare: false, | ||
ForbidFocus: false, | ||
AllowHaveLen0: false, | ||
ForceExpectTo: false, | ||
} | ||
|
||
theLinter := linter.NewGinkgoLinter(config) | ||
a := &analysis.Analyzer{ | ||
Name: "ginkgolinter", | ||
Doc: fmt.Sprintf(doc, version.Version()), | ||
Run: theLinter.Run, | ||
} | ||
|
||
var ignored bool | ||
a.Flags.Init("ginkgolinter", flag.ExitOnError) | ||
a.Flags.Var(&config.SuppressLen, "suppress-len-assertion", "Suppress warning for wrong length assertions") | ||
a.Flags.Var(&config.SuppressNil, "suppress-nil-assertion", "Suppress warning for wrong nil assertions") | ||
a.Flags.Var(&config.SuppressErr, "suppress-err-assertion", "Suppress warning for wrong error assertions") | ||
a.Flags.Var(&config.SuppressCompare, "suppress-compare-assertion", "Suppress warning for wrong comparison assertions") | ||
a.Flags.Var(&config.SuppressAsync, "suppress-async-assertion", "Suppress warning for function call in async assertion, like Eventually") | ||
a.Flags.Var(&config.SuppressTypeCompare, "suppress-type-compare-assertion", "Suppress warning for comparing values from different types, like int32 and uint32") | ||
a.Flags.Var(&config.AllowHaveLen0, "allow-havelen-0", "Do not warn for HaveLen(0); default = false") | ||
a.Flags.Var(&config.ForceExpectTo, "force-expect-to", "force using `Expect` with `To`, `ToNot` or `NotTo`. reject using `Expect` with `Should` or `ShouldNot`; default = false (not forced)") | ||
a.Flags.BoolVar(&ignored, "suppress-focus-container", true, "Suppress warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt. Deprecated and ignored: use --forbid-focus-container instead") | ||
a.Flags.Var(&config.ForbidFocus, "forbid-focus-container", "trigger a warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt; default = false.") | ||
|
||
return a | ||
} | ||
|
||
// Analyzer is the interface to go_vet | ||
var Analyzer = NewAnalyzer() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters