support patch reading from env var
This commit is contained in:
parent
9dd2baf8bd
commit
e73a876b0f
@ -228,6 +228,7 @@ func (e *Executor) runAnalysis(ctx context.Context, args []string) (chan result.
|
||||
}
|
||||
runner := pkg.SimpleRunner{
|
||||
Processors: []processors.Processor{
|
||||
processors.NewPathPrettifier(), // must be before diff processor at least
|
||||
processors.NewExclude(excludeTotalPattern),
|
||||
processors.NewCgo(),
|
||||
processors.NewNolint(fset),
|
||||
@ -236,7 +237,6 @@ func (e *Executor) runAnalysis(ctx context.Context, args []string) (chan result.
|
||||
processors.NewMaxPerFileFromLinter(),
|
||||
processors.NewMaxSameIssues(e.cfg.Issues.MaxSameIssues),
|
||||
processors.NewMaxFromLinter(e.cfg.Issues.MaxIssuesPerLinter),
|
||||
processors.NewPathPrettifier(),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/golangci/golangci-lint/pkg/result"
|
||||
"github.com/golangci/revgrep"
|
||||
@ -14,6 +16,7 @@ type Diff struct {
|
||||
onlyNew bool
|
||||
fromRev string
|
||||
patchFilePath string
|
||||
patch string
|
||||
}
|
||||
|
||||
var _ Processor = Diff{}
|
||||
@ -23,6 +26,7 @@ func NewDiff(onlyNew bool, fromRev, patchFilePath string) *Diff {
|
||||
onlyNew: onlyNew,
|
||||
fromRev: fromRev,
|
||||
patchFilePath: patchFilePath,
|
||||
patch: os.Getenv("GOLANGCI_DIFF_PROCESSOR_PATCH"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +35,7 @@ func (p Diff) Name() string {
|
||||
}
|
||||
|
||||
func (p Diff) Process(issues []result.Issue) ([]result.Issue, error) {
|
||||
if !p.onlyNew && p.fromRev == "" && p.patchFilePath == "" { // no need to work
|
||||
if !p.onlyNew && p.fromRev == "" && p.patchFilePath == "" && p.patch == "" { // no need to work
|
||||
return issues, nil
|
||||
}
|
||||
|
||||
@ -42,7 +46,10 @@ func (p Diff) Process(issues []result.Issue) ([]result.Issue, error) {
|
||||
return nil, fmt.Errorf("can't read from pathc file %s: %s", p.patchFilePath, err)
|
||||
}
|
||||
patchReader = bytes.NewReader(patch)
|
||||
} else if p.patch != "" {
|
||||
patchReader = strings.NewReader(p.patch)
|
||||
}
|
||||
|
||||
c := revgrep.Checker{
|
||||
Patch: patchReader,
|
||||
RevisionFrom: p.fromRev,
|
||||
|
@ -145,7 +145,8 @@ func (r *SimpleRunner) processIssues(ctx context.Context, issues []result.Issue)
|
||||
newIssues, err := p.Process(issues)
|
||||
elapsed := time.Since(startedAt)
|
||||
if elapsed > 50*time.Millisecond {
|
||||
logrus.Infof("Result processor %s took %s", p.Name(), elapsed)
|
||||
logrus.Infof("Result processor %s took %s and transformed %d -> %d issues",
|
||||
p.Name(), elapsed, len(issues), len(newIssues))
|
||||
}
|
||||
if err != nil {
|
||||
logrus.Warnf("Can't process result by %s processor: %s", p.Name(), err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user