Skip to content

Commit bb27c1c

Browse files
committed
use config include paths
`exclude_paths` in engine config are deprecated, and no longer provided to engines. This updates this engine to use `include_paths`.
1 parent bbef627 commit bb27c1c

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

codeclimate-golint.go

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
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

1615
func 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-
5939
func lintFile(fullPath string, relativePath string, minConfidence float64) {
6040
linter := new(lint.Linter)
6141

0 commit comments

Comments
 (0)