6
6
"github.com/golang/lint"
7
7
"io/ioutil"
8
8
"os"
9
- "sort"
10
9
"strconv"
11
10
"strings"
12
11
)
@@ -15,47 +14,28 @@ const defaultMinConfidence = 0.8
15
14
16
15
func main () {
17
16
rootPath := "/code/"
18
- analysisFiles , err := engine .GoFileWalk (rootPath )
17
+
18
+ config , err := engine .LoadConfig ()
19
19
if err != nil {
20
- fmt .Fprintf (os .Stderr , "Error initializing : %s" , err )
20
+ fmt .Fprintf (os .Stderr , "Error loading config : %s" , err )
21
21
os .Exit (1 )
22
22
}
23
23
24
- config , err := engine .LoadConfig ( )
24
+ analysisFiles , err := engine .GoFileWalk ( rootPath , engine . IncludePaths ( rootPath , config ) )
25
25
if err != nil {
26
- fmt .Fprintf (os .Stderr , "Error loading config : %s" , err )
26
+ fmt .Fprintf (os .Stderr , "Error initializing : %s" , err )
27
27
os .Exit (1 )
28
28
}
29
29
30
- excludedFiles := getExcludedFiles (config )
31
30
minConfidence := getMinConfidence (config )
32
31
33
32
for _ , path := range analysisFiles {
34
33
relativePath := strings .SplitAfter (path , rootPath )[1 ]
35
- if isFileExcluded (relativePath , excludedFiles ) {
36
- continue
37
- }
38
34
39
35
lintFile (path , relativePath , minConfidence )
40
36
}
41
37
}
42
38
43
- func getExcludedFiles (config engine.Config ) []string {
44
- excludedFiles := []string {}
45
- if config ["exclude_paths" ] != nil {
46
- for _ , file := range config ["exclude_paths" ].([]interface {}) {
47
- excludedFiles = append (excludedFiles , file .(string ))
48
- }
49
- sort .Strings (excludedFiles )
50
- }
51
- return excludedFiles
52
- }
53
-
54
- func isFileExcluded (filePath string , excludedFiles []string ) bool {
55
- i := sort .SearchStrings (excludedFiles , filePath )
56
- return i < len (excludedFiles ) && excludedFiles [i ] == filePath
57
- }
58
-
59
39
func lintFile (fullPath string , relativePath string , minConfidence float64 ) {
60
40
linter := new (lint.Linter )
61
41
0 commit comments