@@ -3,9 +3,7 @@ package golinters
3
3
import (
4
4
"context"
5
5
"fmt"
6
- "go/build"
7
6
"io/ioutil"
8
- "path/filepath"
9
7
10
8
"github.com/golang/lint"
11
9
"github.com/golangci/golangci-lint/pkg/result"
@@ -19,17 +17,8 @@ func (Golint) Name() string {
19
17
20
18
func (g Golint ) Run (ctx context.Context , lintCtx * Context ) ([]result.Issue , error ) {
21
19
var issues []result.Issue
22
- if lintCtx .Paths .IsDirsRun {
23
- for _ , path := range lintCtx .Paths .Dirs { // TODO: support exclusion of test files
24
- i , err := lintDir (path , lintCtx .RunCfg ().Golint .MinConfidence )
25
- if err != nil {
26
- // TODO: skip and warn
27
- return nil , fmt .Errorf ("can't lint dir %s: %s" , path , err )
28
- }
29
- issues = append (issues , i ... )
30
- }
31
- } else {
32
- i , err := lintFiles (lintCtx .RunCfg ().Golint .MinConfidence , lintCtx .Paths .Files ... )
20
+ for _ , pkgFiles := range lintCtx .Paths .FilesGrouppedByDirs () {
21
+ i , err := lintFiles (lintCtx .RunCfg ().Golint .MinConfidence , pkgFiles ... )
33
22
if err != nil {
34
23
// TODO: skip and warn
35
24
return nil , fmt .Errorf ("can't lint files %s: %s" , lintCtx .Paths .Files , err )
@@ -40,35 +29,6 @@ func (g Golint) Run(ctx context.Context, lintCtx *Context) ([]result.Issue, erro
40
29
return issues , nil
41
30
}
42
31
43
- func lintDir (dirname string , minConfidence float64 ) ([]result.Issue , error ) {
44
- pkg , err := build .ImportDir (dirname , 0 )
45
- if err != nil {
46
- if _ , nogo := err .(* build.NoGoError ); nogo {
47
- // Don't complain if the failure is due to no Go source files.
48
- return nil , nil
49
- }
50
-
51
- return nil , fmt .Errorf ("can't import dir %s" , dirname )
52
- }
53
-
54
- return lintImportedPackage (pkg , minConfidence )
55
- }
56
-
57
- func lintImportedPackage (pkg * build.Package , minConfidence float64 ) ([]result.Issue , error ) {
58
- var files []string
59
- files = append (files , pkg .GoFiles ... )
60
- files = append (files , pkg .CgoFiles ... )
61
- files = append (files , pkg .TestGoFiles ... )
62
- files = append (files , pkg .XTestGoFiles ... )
63
- if pkg .Dir != "." {
64
- for i , f := range files {
65
- files [i ] = filepath .Join (pkg .Dir , f )
66
- }
67
- }
68
-
69
- return lintFiles (minConfidence , files ... )
70
- }
71
-
72
32
func lintFiles (minConfidence float64 , filenames ... string ) ([]result.Issue , error ) {
73
33
files := make (map [string ][]byte )
74
34
for _ , filename := range filenames {
0 commit comments