support exclude patterns
This commit is contained in:
parent
6025f670f2
commit
062caa018c
@ -53,6 +53,8 @@ func (e *Executor) initRun() {
|
|||||||
runCmd.Flags().StringSliceVarP(&rc.DisabledLinters, "disable", "D", []string{}, "Disable specific linter")
|
runCmd.Flags().StringSliceVarP(&rc.DisabledLinters, "disable", "D", []string{}, "Disable specific linter")
|
||||||
runCmd.Flags().BoolVar(&rc.EnableAllLinters, "enable-all", false, "Enable all linters")
|
runCmd.Flags().BoolVar(&rc.EnableAllLinters, "enable-all", false, "Enable all linters")
|
||||||
runCmd.Flags().BoolVar(&rc.DisableAllLinters, "disable-all", false, "Disable all linters")
|
runCmd.Flags().BoolVar(&rc.DisableAllLinters, "disable-all", false, "Disable all linters")
|
||||||
|
|
||||||
|
runCmd.Flags().StringSliceVarP(&rc.ExcludePatterns, "exclude", "e", config.DefaultExcludePatterns, "Exclude issue by regexp")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e Executor) executeRun(cmd *cobra.Command, args []string) {
|
func (e Executor) executeRun(cmd *cobra.Command, args []string) {
|
||||||
@ -92,7 +94,8 @@ func (e Executor) executeRun(cmd *cobra.Command, args []string) {
|
|||||||
runner := pkg.SimpleRunner{
|
runner := pkg.SimpleRunner{
|
||||||
Processors: []processors.Processor{
|
Processors: []processors.Processor{
|
||||||
processors.MaxLinterIssuesPerFile{},
|
processors.MaxLinterIssuesPerFile{},
|
||||||
//processors.UniqByLineProcessor{},
|
processors.UniqByLineProcessor{},
|
||||||
|
processors.NewExcludeProcessor(fmt.Sprintf("(%s)", strings.Join(e.cfg.Run.ExcludePatterns, "|"))),
|
||||||
processors.NewPathPrettifier(),
|
processors.NewPathPrettifier(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ const (
|
|||||||
|
|
||||||
var OutFormats = []string{OutFormatColoredLineNumber, OutFormatLineNumber, OutFormatJSON}
|
var OutFormats = []string{OutFormatColoredLineNumber, OutFormatLineNumber, OutFormatJSON}
|
||||||
|
|
||||||
|
var DefaultExcludePatterns = []string{"should have comment", "comment on exported method"}
|
||||||
|
|
||||||
type Common struct {
|
type Common struct {
|
||||||
IsVerbose bool
|
IsVerbose bool
|
||||||
CPUProfilePath string
|
CPUProfilePath string
|
||||||
@ -44,6 +46,8 @@ type Run struct {
|
|||||||
DisabledLinters []string
|
DisabledLinters []string
|
||||||
EnableAllLinters bool
|
EnableAllLinters bool
|
||||||
DisableAllLinters bool
|
DisableAllLinters bool
|
||||||
|
|
||||||
|
ExcludePatterns []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -45,6 +45,6 @@ func installBinary(t *testing.T) {
|
|||||||
|
|
||||||
func testOneSource(t *testing.T, sourcePath string) {
|
func testOneSource(t *testing.T, sourcePath string) {
|
||||||
goErrchkBin := filepath.Join(runtime.GOROOT(), "test", "errchk")
|
goErrchkBin := filepath.Join(runtime.GOROOT(), "test", "errchk")
|
||||||
cmd := exec.Command(goErrchkBin, binName, "run", sourcePath)
|
cmd := exec.Command(goErrchkBin, binName, "run", "--enable-all", sourcePath)
|
||||||
runGoErrchk(cmd, t)
|
runGoErrchk(cmd, t)
|
||||||
}
|
}
|
||||||
|
12
pkg/golinters/testdata/golint.go
vendored
12
pkg/golinters/testdata/golint.go
vendored
@ -1,3 +1,15 @@
|
|||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
var go_lint string // ERROR "don't use underscores in Go names; var go_lint should be goLint"
|
var go_lint string // ERROR "don't use underscores in Go names; var go_lint should be goLint"
|
||||||
|
|
||||||
|
func ExportedFuncWithNoComment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
var ExportedVarWithNoComment string
|
||||||
|
|
||||||
|
type ExportedStructWithNoComment struct{}
|
||||||
|
|
||||||
|
type ExportedInterfaceWithNoComment interface{}
|
||||||
|
|
||||||
|
// Bad comment // ERROR "comment on exported function ExportedFuncWithBadComment should be of the form .ExportedFuncWithBadComment \.\.\.."
|
||||||
|
func ExportedFuncWithBadComment() {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user