mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
Fix #72: match more autogenerated files patterns.
We skip all issues from autogenerated files. Also reuse AST parsing for nolint and autogenerated exclude processors: decrease processing time on golang source code from 3s to 800ms.
This commit is contained in:
parent
46088deacf
commit
adb6be78bb
11 changed files with 232 additions and 87 deletions
|
@ -3,7 +3,6 @@ package commands
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -192,10 +191,6 @@ func (e *Executor) runAnalysis(ctx context.Context, args []string) (<-chan resul
|
|||
if len(excludePatterns) != 0 {
|
||||
excludeTotalPattern = fmt.Sprintf("(%s)", strings.Join(excludePatterns, "|"))
|
||||
}
|
||||
fset := token.NewFileSet()
|
||||
if lintCtx.Program != nil {
|
||||
fset = lintCtx.Program.Fset
|
||||
}
|
||||
|
||||
skipFilesProcessor, err := processors.NewSkipFiles(e.cfg.Run.SkipFiles)
|
||||
if err != nil {
|
||||
|
@ -204,12 +199,13 @@ func (e *Executor) runAnalysis(ctx context.Context, args []string) (<-chan resul
|
|||
|
||||
runner := lint.SimpleRunner{
|
||||
Processors: []processors.Processor{
|
||||
processors.NewPathPrettifier(), // must be before diff processor at least
|
||||
processors.NewPathPrettifier(), // must be before diff, nolint and exclude autogenerated processor at least
|
||||
processors.NewCgo(),
|
||||
skipFilesProcessor,
|
||||
|
||||
processors.NewAutogeneratedExclude(lintCtx.ASTCache),
|
||||
processors.NewExclude(excludeTotalPattern),
|
||||
processors.NewNolint(fset),
|
||||
processors.NewNolint(lintCtx.ASTCache),
|
||||
|
||||
processors.NewUniqByLine(),
|
||||
processors.NewDiff(e.cfg.Issues.Diff, e.cfg.Issues.DiffFromRevision, e.cfg.Issues.DiffPatchFilePath),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue