fixes after testing all linters on self repo
This commit is contained in:
parent
5dc876c260
commit
511b04de5e
@ -65,7 +65,7 @@ func (e *Executor) initRun() {
|
|||||||
runCmd.Flags().BoolVar(&rc.Megacheck.EnableUnused, "megacheck.unused", true, "Megacheck: run Unused sub-linter: unused checks Go code for unused constants, variables, functions and types")
|
runCmd.Flags().BoolVar(&rc.Megacheck.EnableUnused, "megacheck.unused", true, "Megacheck: run Unused sub-linter: unused checks Go code for unused constants, variables, functions and types")
|
||||||
|
|
||||||
runCmd.Flags().IntVar(&rc.Dupl.Threshold, "dupl.threshold",
|
runCmd.Flags().IntVar(&rc.Dupl.Threshold, "dupl.threshold",
|
||||||
20, "Dupl: Minimal threshold to detect copy-paste")
|
150, "Dupl: Minimal threshold to detect copy-paste")
|
||||||
|
|
||||||
runCmd.Flags().IntVar(&rc.Goconst.MinStringLen, "goconst.min-len",
|
runCmd.Flags().IntVar(&rc.Goconst.MinStringLen, "goconst.min-len",
|
||||||
3, "Goconst: minimum constant string length")
|
3, "Goconst: minimum constant string length")
|
||||||
@ -79,7 +79,9 @@ func (e *Executor) initRun() {
|
|||||||
|
|
||||||
runCmd.Flags().DurationVar(&rc.Deadline, "deadline", time.Second*30, "Deadline for total work")
|
runCmd.Flags().DurationVar(&rc.Deadline, "deadline", time.Second*30, "Deadline for total work")
|
||||||
|
|
||||||
runCmd.Flags().StringSliceVarP(&rc.ExcludePatterns, "exclude", "e", config.DefaultExcludePatterns, "Exclude issue by regexp")
|
runCmd.Flags().StringSliceVarP(&rc.ExcludePatterns, "exclude", "e", []string{}, "Exclude issue by regexp")
|
||||||
|
runCmd.Flags().BoolVar(&rc.UseDefaultExcludes, "exclude-use-default", true,
|
||||||
|
fmt.Sprintf("Use or not use default excludes: (%s)", strings.Join(config.DefaultExcludePatterns, "|")))
|
||||||
|
|
||||||
runCmd.Flags().IntVar(&rc.MaxIssuesPerLinter, "max-issues-per-linter", 50, "Maximum issues count per one linter. Set to 0 to disable")
|
runCmd.Flags().IntVar(&rc.MaxIssuesPerLinter, "max-issues-per-linter", 50, "Maximum issues count per one linter. Set to 0 to disable")
|
||||||
|
|
||||||
@ -197,9 +199,17 @@ func (e *Executor) runAnalysis(ctx context.Context, args []string) (chan result.
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
excludePatterns := e.cfg.Run.ExcludePatterns
|
||||||
|
if e.cfg.Run.UseDefaultExcludes {
|
||||||
|
excludePatterns = append(excludePatterns, config.DefaultExcludePatterns...)
|
||||||
|
}
|
||||||
|
var excludeTotalPattern string
|
||||||
|
if len(excludePatterns) != 0 {
|
||||||
|
excludeTotalPattern = fmt.Sprintf("(%s)", strings.Join(excludePatterns, "|"))
|
||||||
|
}
|
||||||
runner := pkg.SimpleRunner{
|
runner := pkg.SimpleRunner{
|
||||||
Processors: []processors.Processor{
|
Processors: []processors.Processor{
|
||||||
processors.NewExclude(fmt.Sprintf("(%s)", strings.Join(e.cfg.Run.ExcludePatterns, "|"))),
|
processors.NewExclude(excludeTotalPattern),
|
||||||
processors.NewNolint(lintCtx.Program.Fset),
|
processors.NewNolint(lintCtx.Program.Fset),
|
||||||
processors.NewUniqByLine(),
|
processors.NewUniqByLine(),
|
||||||
processors.NewDiff(e.cfg.Run.Diff, e.cfg.Run.DiffFromRevision, e.cfg.Run.DiffPatchFilePath),
|
processors.NewDiff(e.cfg.Run.Diff, e.cfg.Run.DiffFromRevision, e.cfg.Run.DiffPatchFilePath),
|
||||||
|
@ -14,7 +14,13 @@ const (
|
|||||||
|
|
||||||
var OutFormats = []string{OutFormatColoredLineNumber, OutFormatLineNumber, OutFormatJSON}
|
var OutFormats = []string{OutFormatColoredLineNumber, OutFormatLineNumber, OutFormatJSON}
|
||||||
|
|
||||||
var DefaultExcludePatterns = []string{"should have comment", "comment on exported method"}
|
var DefaultExcludePatterns = []string{
|
||||||
|
"should have comment",
|
||||||
|
"comment on exported method",
|
||||||
|
"G104", // disable what errcheck does: it reports on Close etc
|
||||||
|
"G204", // Subprocess launching should be audited: too lot false positives
|
||||||
|
"G304", // Potential file inclusion via variable: `src, err := ioutil.ReadFile(filename)`
|
||||||
|
}
|
||||||
|
|
||||||
type Common struct {
|
type Common struct {
|
||||||
IsVerbose bool
|
IsVerbose bool
|
||||||
@ -22,7 +28,7 @@ type Common struct {
|
|||||||
Concurrency int
|
Concurrency int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Run struct {
|
type Run struct { // nolint:maligned
|
||||||
Args []string
|
Args []string
|
||||||
|
|
||||||
BuildTags []string
|
BuildTags []string
|
||||||
@ -76,7 +82,8 @@ type Run struct {
|
|||||||
EnableAllLinters bool
|
EnableAllLinters bool
|
||||||
DisableAllLinters bool
|
DisableAllLinters bool
|
||||||
|
|
||||||
ExcludePatterns []string
|
ExcludePatterns []string
|
||||||
|
UseDefaultExcludes bool
|
||||||
|
|
||||||
Deadline time.Duration
|
Deadline time.Duration
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ func (Gas) Name() string {
|
|||||||
|
|
||||||
func (lint Gas) Run(ctx context.Context, lintCtx *Context) ([]result.Issue, error) {
|
func (lint Gas) Run(ctx context.Context, lintCtx *Context) ([]result.Issue, error) {
|
||||||
gasConfig := gas.NewConfig()
|
gasConfig := gas.NewConfig()
|
||||||
enabledRules := rules.Generate(rules.NewRuleFilter(true, "G104")) // disable what errcheck does: it reports on Close etc
|
enabledRules := rules.Generate()
|
||||||
logger := log.New(ioutil.Discard, "", 0)
|
logger := log.New(ioutil.Discard, "", 0)
|
||||||
analyzer := gas.NewAnalyzer(gasConfig, logger)
|
analyzer := gas.NewAnalyzer(gasConfig, logger)
|
||||||
analyzer.LoadRules(enabledRules.Builders())
|
analyzer.LoadRules(enabledRules.Builders())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user