Skip to content

Commit 9ffe218

Browse files
author
Chris Hulton
authored
Exit on error with proper error format (#17)
Fixes bug where certain errors are being parsed as issues.
1 parent 61bd18e commit 9ffe218

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

codeclimate-golint.go

+6-19
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,16 @@ func lintFile(fullPath string, relativePath string, minConfidence float64) {
4141

4242
code, err := ioutil.ReadFile(fullPath)
4343
if err != nil {
44-
warning := &engine.Warning{
45-
Description: "Could not read file",
46-
Location: &engine.Location{
47-
Path: fullPath,
48-
Lines: &engine.LinesOnlyPosition{
49-
Begin: 1,
50-
End: 1,
51-
},
52-
},
53-
}
54-
engine.PrintWarning(warning)
44+
fmt.Fprintf(os.Stderr, "Could not read file: %v\n", fullPath)
45+
fmt.Fprintf(os.Stderr, "Error %v\n", err)
46+
os.Exit(1)
5547
}
5648

5749
problems, err := linter.Lint(fullPath, code)
5850
if err != nil {
59-
warningDesc := fmt.Sprintf("Could not lint file (%s)", err)
60-
warning := &engine.Warning{
61-
Description: warningDesc,
62-
Location: &engine.Location{
63-
Path: fullPath,
64-
},
65-
}
66-
engine.PrintWarning(warning)
51+
fmt.Fprintf(os.Stderr, "Could not lint file: %v\n", fullPath)
52+
fmt.Fprintf(os.Stderr, "Error %v\n", err)
53+
os.Exit(1)
6754
}
6855

6956
for _, problem := range problems {

0 commit comments

Comments
 (0)