66 "github.com/golang/lint"
77 "io/ioutil"
88 "os"
9- "sort"
109 "strconv"
1110 "strings"
1211)
@@ -15,47 +14,28 @@ const defaultMinConfidence = 0.8
1514
1615func main () {
1716 rootPath := "/code/"
18- analysisFiles , err := engine .GoFileWalk (rootPath )
17+
18+ config , err := engine .LoadConfig ()
1919 if err != nil {
20- fmt .Fprintf (os .Stderr , "Error initializing : %s" , err )
20+ fmt .Fprintf (os .Stderr , "Error loading config : %s" , err )
2121 os .Exit (1 )
2222 }
2323
24- config , err := engine .LoadConfig ( )
24+ analysisFiles , err := engine .GoFileWalk ( rootPath , engine . IncludePaths ( rootPath , config ) )
2525 if err != nil {
26- fmt .Fprintf (os .Stderr , "Error loading config : %s" , err )
26+ fmt .Fprintf (os .Stderr , "Error initializing : %s" , err )
2727 os .Exit (1 )
2828 }
2929
30- excludedFiles := getExcludedFiles (config )
3130 minConfidence := getMinConfidence (config )
3231
3332 for _ , path := range analysisFiles {
3433 relativePath := strings .SplitAfter (path , rootPath )[1 ]
35- if isFileExcluded (relativePath , excludedFiles ) {
36- continue
37- }
3834
3935 lintFile (path , relativePath , minConfidence )
4036 }
4137}
4238
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-
5939func lintFile (fullPath string , relativePath string , minConfidence float64 ) {
6040 linter := new (lint.Linter )
6141
0 commit comments