Repository navigation
Expand file tree
/
Copy pathcmd.go
More file actions
816 lines (728 loc) · 19.7 KB
/
Copy pathcmd.go
File metadata and controls
816 lines (728 loc) · 19.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
package lintcmd
import (
"crypto/sha256"
"flag"
"fmt"
"go/build"
"go/token"
"io"
"log"
"os"
"os/signal"
"path/filepath"
"regexp"
"runtime"
"runtime/pprof"
"runtime/trace"
"sort"
"strconv"
"strings"
"sync"
"time"
"unicode"
"honnef.co/go/tools/analysis/lint"
"honnef.co/go/tools/config"
"honnef.co/go/tools/go/loader"
"honnef.co/go/tools/internal/cache"
"honnef.co/go/tools/lintcmd/runner"
"honnef.co/go/tools/lintcmd/version"
"honnef.co/go/tools/unused"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/buildutil"
"golang.org/x/tools/go/packages"
)
type ignore interface {
Match(p problem) bool
}
type lineIgnore struct {
File string
Line int
Checks []string
Matched bool
Pos token.Position
}
func (li *lineIgnore) Match(p problem) bool {
pos := p.Position
if pos.Filename != li.File || pos.Line != li.Line {
return false
}
for _, c := range li.Checks {
if m, _ := filepath.Match(c, p.Category); m {
li.Matched = true
return true
}
}
return false
}
func (li *lineIgnore) String() string {
matched := "not matched"
if li.Matched {
matched = "matched"
}
return fmt.Sprintf("%s:%d %s (%s)", li.File, li.Line, strings.Join(li.Checks, ", "), matched)
}
type fileIgnore struct {
File string
Checks []string
}
func (fi *fileIgnore) Match(p problem) bool {
if p.Position.Filename != fi.File {
return false
}
for _, c := range fi.Checks {
if m, _ := filepath.Match(c, p.Category); m {
return true
}
}
return false
}
type severity uint8
const (
severityError severity = iota
severityWarning
severityIgnored
)
func (s severity) String() string {
switch s {
case severityError:
return "error"
case severityWarning:
return "warning"
case severityIgnored:
return "ignored"
default:
return fmt.Sprintf("Severity(%d)", s)
}
}
// problem represents a problem in some source code.
type problem struct {
runner.Diagnostic
Severity severity
}
func (p problem) equal(o problem) bool {
return p.Position == o.Position &&
p.End == o.End &&
p.Message == o.Message &&
p.Category == o.Category &&
p.Severity == o.Severity
}
func (p *problem) String() string {
return fmt.Sprintf("%s (%s)", p.Message, p.Category)
}
// A linter lints Go source code.
type linter struct {
Checkers []*analysis.Analyzer
Config config.Config
Runner *runner.Runner
}
func failed(res runner.Result) []problem {
var problems []problem
for _, e := range res.Errors {
switch e := e.(type) {
case packages.Error:
msg := e.Msg
if len(msg) != 0 && msg[0] == '\n' {
// TODO(dh): See https://github.com/golang/go/issues/32363
msg = msg[1:]
}
var posn token.Position
if e.Pos == "" {
// Under certain conditions (malformed package
// declarations, multiple packages in the same
// directory), go list emits an error on stderr
// instead of JSON. Those errors do not have
// associated position information in
// go/packages.Error, even though the output on
// stderr may contain it.
if p, n, err := parsePos(msg); err == nil {
if abs, err := filepath.Abs(p.Filename); err == nil {
p.Filename = abs
}
posn = p
msg = msg[n+2:]
}
} else {
var err error
posn, _, err = parsePos(e.Pos)
if err != nil {
panic(fmt.Sprintf("internal error: %s", e))
}
}
p := problem{
Diagnostic: runner.Diagnostic{
Position: posn,
Message: msg,
Category: "compile",
},
Severity: severityError,
}
problems = append(problems, p)
case error:
p := problem{
Diagnostic: runner.Diagnostic{
Position: token.Position{},
Message: e.Error(),
Category: "compile",
},
Severity: severityError,
}
problems = append(problems, p)
}
}
return problems
}
type unusedKey struct {
pkgPath string
base string
line int
name string
}
type unusedPair struct {
key unusedKey
obj unused.SerializedObject
}
func success(allowedChecks map[string]bool, res runner.ResultData) []problem {
diags := res.Diagnostics
var problems []problem
for _, diag := range diags {
if !allowedChecks[diag.Category] {
continue
}
problems = append(problems, problem{Diagnostic: diag})
}
return problems
}
func filterIgnored(problems []problem, res runner.ResultData, allowedAnalyzers map[string]bool) ([]problem, error) {
couldveMatched := func(ig *lineIgnore) bool {
for _, c := range ig.Checks {
if c == "U1000" {
// We never want to flag ignores for U1000,
// because U1000 isn't local to a single
// package. For example, an identifier may
// ignore would only fire when not analyzing
// tests. To avoid spurious "useless ignore"
// warnings, just never flag U1000.
return false
}
// Even though the runner always runs all analyzers, we
// still only flag unmatched ignores for the set of
// analyzers the user has expressed interest in. That way,
// `staticcheck -checks=SA1000` won't complain about an
// unmatched ignore for an unrelated check.
if allowedAnalyzers[c] {
return true
}
}
return false
}
ignores, moreProblems := parseDirectives(res.Directives)
for _, ig := range ignores {
for i := range problems {
p := &problems[i]
if ig.Match(*p) {
p.Severity = severityIgnored
}
}
if ig, ok := ig.(*lineIgnore); ok && !ig.Matched && couldveMatched(ig) {
p := problem{
Diagnostic: runner.Diagnostic{
Position: ig.Pos,
Message: "this linter directive didn't match anything; should it be removed?",
Category: "staticcheck",
},
}
moreProblems = append(moreProblems, p)
}
}
return append(problems, moreProblems...), nil
}
func newLinter(cfg config.Config) (*linter, error) {
r, err := runner.New(cfg)
if err != nil {
return nil, err
}
return &linter{
Config: cfg,
Runner: r,
}, nil
}
func (l *linter) SetGoVersion(n int) {
l.Runner.GoVersion = n
}
func (l *linter) Lint(cfg *packages.Config, patterns []string) (problems []problem, warnings []string, err error) {
results, err := l.Runner.Run(cfg, l.Checkers, patterns)
if err != nil {
return nil, nil, err
}
if len(results) == 0 && err == nil {
// TODO(dh): emulate Go's behavior more closely once we have
// access to go list's Match field.
for _, pattern := range patterns {
fmt.Fprintf(os.Stderr, "warning: %q matched no packages\n", pattern)
}
}
analyzerNames := make([]string, len(l.Checkers))
for i, a := range l.Checkers {
analyzerNames[i] = a.Name
}
used := map[unusedKey]bool{}
var unuseds []unusedPair
for _, res := range results {
if len(res.Errors) > 0 && !res.Failed {
panic("package has errors but isn't marked as failed")
}
if res.Failed {
problems = append(problems, failed(res)...)
} else {
if res.Skipped {
warnings = append(warnings, fmt.Sprintf("skipped package %s because it is too large", res.Package))
continue
}
if !res.Initial {
continue
}
allowedAnalyzers := filterAnalyzerNames(analyzerNames, res.Config.Checks)
resd, err := res.Load()
if err != nil {
return nil, nil, err
}
ps := success(allowedAnalyzers, resd)
filtered, err := filterIgnored(ps, resd, allowedAnalyzers)
if err != nil {
return nil, nil, err
}
problems = append(problems, filtered...)
for _, obj := range resd.Unused.Used {
// FIXME(dh): pick the object whose filename does not include $GOROOT
key := unusedKey{
pkgPath: res.Package.PkgPath,
base: filepath.Base(obj.Position.Filename),
line: obj.Position.Line,
name: obj.Name,
}
used[key] = true
}
if allowedAnalyzers["U1000"] {
for _, obj := range resd.Unused.Unused {
key := unusedKey{
pkgPath: res.Package.PkgPath,
base: filepath.Base(obj.Position.Filename),
line: obj.Position.Line,
name: obj.Name,
}
unuseds = append(unuseds, unusedPair{key, obj})
if _, ok := used[key]; !ok {
used[key] = false
}
}
}
}
}
for _, uo := range unuseds {
if used[uo.key] {
continue
}
if uo.obj.InGenerated {
continue
}
problems = append(problems, problem{
Diagnostic: runner.Diagnostic{
Position: uo.obj.DisplayPosition,
Message: fmt.Sprintf("%s %s is unused", uo.obj.Kind, uo.obj.Name),
Category: "U1000",
},
})
}
if len(problems) == 0 {
return nil, warnings, nil
}
sort.Slice(problems, func(i, j int) bool {
pi := problems[i].Position
pj := problems[j].Position
if pi.Filename != pj.Filename {
return pi.Filename < pj.Filename
}
if pi.Line != pj.Line {
return pi.Line < pj.Line
}
if pi.Column != pj.Column {
return pi.Column < pj.Column
}
return problems[i].Message < problems[j].Message
})
var out []problem
out = append(out, problems[0])
for i, p := range problems[1:] {
// We may encounter duplicate problems because one file
// can be part of many packages.
if !problems[i].equal(p) {
out = append(out, p)
}
}
return out, warnings, nil
}
func filterAnalyzerNames(analyzers []string, checks []string) map[string]bool {
allowedChecks := map[string]bool{}
for _, check := range checks {
b := true
if len(check) > 1 && check[0] == '-' {
b = false
check = check[1:]
}
if check == "*" || check == "all" {
// Match all
for _, c := range analyzers {
allowedChecks[c] = b
}
} else if strings.HasSuffix(check, "*") {
// Glob
prefix := check[:len(check)-1]
isCat := strings.IndexFunc(prefix, func(r rune) bool { return unicode.IsNumber(r) }) == -1
for _, a := range analyzers {
idx := strings.IndexFunc(a, func(r rune) bool { return unicode.IsNumber(r) })
if isCat {
// Glob is S*, which should match S1000 but not SA1000
cat := a[:idx]
if prefix == cat {
allowedChecks[a] = b
}
} else {
// Glob is S1*
if strings.HasPrefix(a, prefix) {
allowedChecks[a] = b
}
}
}
} else {
// Literal check name
allowedChecks[check] = b
}
}
return allowedChecks
}
var posRe = regexp.MustCompile(`^(.+?):(\d+)(?::(\d+)?)?`)
func parsePos(pos string) (token.Position, int, error) {
if pos == "-" || pos == "" {
return token.Position{}, 0, nil
}
parts := posRe.FindStringSubmatch(pos)
if parts == nil {
return token.Position{}, 0, fmt.Errorf("internal error: malformed position %q", pos)
}
file := parts[1]
line, _ := strconv.Atoi(parts[2])
col, _ := strconv.Atoi(parts[3])
return token.Position{
Filename: file,
Line: line,
Column: col,
}, len(parts[0]), nil
}
func usage(name string, flags *flag.FlagSet) func() {
return func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", name)
fmt.Fprintf(os.Stderr, "\t%s [flags] # runs on package in current directory\n", name)
fmt.Fprintf(os.Stderr, "\t%s [flags] packages\n", name)
fmt.Fprintf(os.Stderr, "\t%s [flags] directory\n", name)
fmt.Fprintf(os.Stderr, "\t%s [flags] files... # must be a single package\n", name)
fmt.Fprintf(os.Stderr, "Flags:\n")
flags.PrintDefaults()
}
}
type list []string
func (list *list) String() string {
return `"` + strings.Join(*list, ",") + `"`
}
func (list *list) Set(s string) error {
if s == "" {
*list = nil
return nil
}
*list = strings.Split(s, ",")
return nil
}
func FlagSet(name string) *flag.FlagSet {
flags := flag.NewFlagSet("", flag.ExitOnError)
flags.Usage = usage(name, flags)
flags.String("tags", "", "List of `build tags`")
flags.Bool("tests", true, "Include tests")
flags.Bool("version", false, "Print version and exit")
flags.Bool("show-ignored", false, "Don't filter ignored problems")
flags.String("f", "text", "Output `format` (valid choices are 'stylish', 'text' and 'json')")
flags.String("explain", "", "Print description of `check`")
flags.String("debug.cpuprofile", "", "Write CPU profile to `file`")
flags.String("debug.memprofile", "", "Write memory profile to `file`")
flags.Bool("debug.version", false, "Print detailed version information about this program")
flags.Bool("debug.no-compile-errors", false, "Don't print compile errors")
flags.String("debug.measure-analyzers", "", "Write analysis measurements to `file`. `file` will be opened for appending if it already exists.")
flags.String("debug.trace", "", "Write trace to `file`")
checks := list{"inherit"}
fail := list{"all"}
flags.Var(&checks, "checks", "Comma-separated list of `checks` to enable.")
flags.Var(&fail, "fail", "Comma-separated list of `checks` that can cause a non-zero exit status.")
tags := build.Default.ReleaseTags
v := tags[len(tags)-1][2:]
version := new(lint.VersionFlag)
if err := version.Set(v); err != nil {
panic(fmt.Sprintf("internal error: %s", err))
}
flags.Var(version, "go", "Target Go `version` in the format '1.x'")
return flags
}
func findCheck(cs []*analysis.Analyzer, check string) (*analysis.Analyzer, bool) {
for _, c := range cs {
if c.Name == check {
return c, true
}
}
return nil, false
}
func ProcessFlagSet(cs []*analysis.Analyzer, fs *flag.FlagSet) {
tags := fs.Lookup("tags").Value.(flag.Getter).Get().(string)
tests := fs.Lookup("tests").Value.(flag.Getter).Get().(bool)
goVersion := fs.Lookup("go").Value.(flag.Getter).Get().(int)
theFormatter := fs.Lookup("f").Value.(flag.Getter).Get().(string)
printVersion := fs.Lookup("version").Value.(flag.Getter).Get().(bool)
showIgnored := fs.Lookup("show-ignored").Value.(flag.Getter).Get().(bool)
explain := fs.Lookup("explain").Value.(flag.Getter).Get().(string)
cpuProfile := fs.Lookup("debug.cpuprofile").Value.(flag.Getter).Get().(string)
memProfile := fs.Lookup("debug.memprofile").Value.(flag.Getter).Get().(string)
debugVersion := fs.Lookup("debug.version").Value.(flag.Getter).Get().(bool)
debugNoCompile := fs.Lookup("debug.no-compile-errors").Value.(flag.Getter).Get().(bool)
traceOut := fs.Lookup("debug.trace").Value.(flag.Getter).Get().(string)
var measureAnalyzers func(analysis *analysis.Analyzer, pkg *loader.PackageSpec, d time.Duration)
if path := fs.Lookup("debug.measure-analyzers").Value.(flag.Getter).Get().(string); path != "" {
f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
log.Fatal(err)
}
mu := &sync.Mutex{}
measureAnalyzers = func(analysis *analysis.Analyzer, pkg *loader.PackageSpec, d time.Duration) {
mu.Lock()
defer mu.Unlock()
// FIXME(dh): print pkg.ID
if _, err := fmt.Fprintf(f, "%s\t%s\t%d\n", analysis.Name, pkg, d.Nanoseconds()); err != nil {
log.Println("error writing analysis measurements:", err)
}
}
}
cfg := config.Config{}
cfg.Checks = *fs.Lookup("checks").Value.(*list)
exit := func(code int) {
if cpuProfile != "" {
pprof.StopCPUProfile()
}
if memProfile != "" {
f, err := os.Create(memProfile)
if err != nil {
panic(err)
}
runtime.GC()
pprof.WriteHeapProfile(f)
}
if traceOut != "" {
trace.Stop()
}
os.Exit(code)
}
if cpuProfile != "" {
f, err := os.Create(cpuProfile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
}
if traceOut != "" {
f, err := os.Create(traceOut)
if err != nil {
log.Fatal(err)
}
trace.Start(f)
}
if debugVersion {
version.Verbose()
exit(0)
}
if printVersion {
version.Print()
exit(0)
}
// Validate that the tags argument is well-formed. go/packages
// doesn't detect malformed build flags and returns unhelpful
// errors.
tf := buildutil.TagsFlag{}
if err := tf.Set(tags); err != nil {
fmt.Fprintln(os.Stderr, fmt.Errorf("invalid value %q for flag -tags: %s", tags, err))
exit(1)
}
if explain != "" {
var haystack []*analysis.Analyzer
haystack = append(haystack, cs...)
check, ok := findCheck(haystack, explain)
if !ok {
fmt.Fprintln(os.Stderr, "Couldn't find check", explain)
exit(1)
}
if check.Doc == "" {
fmt.Fprintln(os.Stderr, explain, "has no documentation")
exit(1)
}
fmt.Println(check.Doc)
exit(0)
}
var f formatter
switch theFormatter {
case "text":
f = textFormatter{Diagnostics: os.Stdout, UI: os.Stderr}
case "stylish":
f = &stylishFormatter{Diagnostics: os.Stdout, UI: os.Stderr}
case "json":
f = jsonFormatter{W: os.Stdout}
case "null":
f = nullFormatter{}
default:
fmt.Fprintf(os.Stderr, "unsupported output format %q\n", theFormatter)
exit(2)
}
ps, warnings, err := doLint(cs, fs.Args(), &options{
Tags: tags,
LintTests: tests,
GoVersion: goVersion,
Config: cfg,
PrintAnalyzerMeasurement: measureAnalyzers,
})
if err != nil {
fmt.Fprintln(os.Stderr, err)
exit(1)
}
for _, w := range warnings {
fmt.Fprintln(os.Stderr, "warning:", w)
}
var (
numCompiles int
numErrors int
numWarnings int
numIgnored int
)
fail := *fs.Lookup("fail").Value.(*list)
analyzerNames := make([]string, len(cs))
for i, a := range cs {
analyzerNames[i] = a.Name
}
shouldExit := filterAnalyzerNames(analyzerNames, fail)
shouldExit["staticcheck"] = true
for _, p := range ps {
if p.Category == "compile" && debugNoCompile {
continue
}
if p.Severity == severityIgnored && !showIgnored {
numIgnored++
continue
}
if p.Category == "compile" {
numCompiles++
} else if shouldExit[p.Category] {
numErrors++
} else {
p.Severity = severityWarning
numWarnings++
}
f.Format(p)
}
if f, ok := f.(statter); ok {
f.Stats(len(ps), numErrors+numCompiles, numWarnings, numIgnored)
}
if f, ok := f.(documentationMentioner); ok && (numErrors > 0 || numWarnings > 0) && len(os.Args) > 0 {
f.MentionCheckDocumentation(os.Args[0])
}
if numErrors > 0 || numCompiles > 0 {
exit(1)
}
exit(0)
}
type options struct {
Config config.Config
Tags string
LintTests bool
GoVersion int
PrintAnalyzerMeasurement func(analysis *analysis.Analyzer, pkg *loader.PackageSpec, d time.Duration)
}
func computeSalt() ([]byte, error) {
if version.Version != "devel" {
return []byte(version.Version), nil
}
p, err := os.Executable()
if err != nil {
return nil, err
}
f, err := os.Open(p)
if err != nil {
return nil, err
}
defer f.Close()
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
return nil, err
}
return h.Sum(nil), nil
}
func doLint(cs []*analysis.Analyzer, paths []string, opt *options) ([]problem, []string, error) {
salt, err := computeSalt()
if err != nil {
return nil, nil, fmt.Errorf("could not compute salt for cache: %s", err)
}
cache.SetSalt(salt)
if opt == nil {
opt = &options{}
}
l, err := newLinter(opt.Config)
if err != nil {
return nil, nil, err
}
l.Checkers = cs
l.SetGoVersion(opt.GoVersion)
l.Runner.Stats.PrintAnalyzerMeasurement = opt.PrintAnalyzerMeasurement
cfg := &packages.Config{}
if opt.LintTests {
cfg.Tests = true
}
if opt.Tags != "" {
cfg.BuildFlags = append(cfg.BuildFlags, "-tags", opt.Tags)
}
printStats := func() {
// Individual stats are read atomically, but overall there
// is no synchronisation. For printing rough progress
// information, this doesn't matter.
switch l.Runner.Stats.State() {
case runner.StateInitializing:
fmt.Fprintln(os.Stderr, "Status: initializing")
case runner.StateLoadPackageGraph:
fmt.Fprintln(os.Stderr, "Status: loading package graph")
case runner.StateBuildActionGraph:
fmt.Fprintln(os.Stderr, "Status: building action graph")
case runner.StateProcessing:
fmt.Fprintf(os.Stderr, "Packages: %d/%d initial, %d/%d total; Workers: %d/%d\n",
l.Runner.Stats.ProcessedInitialPackages(),
l.Runner.Stats.InitialPackages(),
l.Runner.Stats.ProcessedPackages(),
l.Runner.Stats.TotalPackages(),
l.Runner.ActiveWorkers(),
l.Runner.TotalWorkers(),
)
case runner.StateFinalizing:
fmt.Fprintln(os.Stderr, "Status: finalizing")
}
}
if len(infoSignals) > 0 {
ch := make(chan os.Signal, 1)
signal.Notify(ch, infoSignals...)
defer signal.Stop(ch)
go func() {
for range ch {
printStats()
}
}()
}
return l.Lint(cfg, paths)
}