Skip to content

Commit ddc0a88

Browse files
committed
Fix #78: log all warnings
1 parent 219a547 commit ddc0a88

File tree

8 files changed

+15
-23
lines changed

8 files changed

+15
-23
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/*.pprof
33
/dist/
44
/.idea/
5+
/test/path

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
test:
2-
go install ./cmd/... # needed for govet and golint
2+
go install ./cmd/... # needed for govet and golint if go < 1.10
33
golangci-lint run -v
44
golangci-lint run --fast --no-config -v
55
golangci-lint run --no-config -v

Diff for: pkg/commands/run_config.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/golangci/golangci-lint/pkg/config"
1111
"github.com/golangci/golangci-lint/pkg/fsutils"
12-
"github.com/golangci/golangci-lint/pkg/logutils"
1312
"github.com/golangci/golangci-lint/pkg/printers"
1413
"github.com/sirupsen/logrus"
1514
"github.com/spf13/pflag"
@@ -84,7 +83,7 @@ func setupConfigFileSearch(args []string) {
8483

8584
absStartPath, err := filepath.Abs(firstArg)
8685
if err != nil {
87-
logutils.HiddenWarnf("Can't make abs path for %q: %s", firstArg, err)
86+
logrus.Warnf("Can't make abs path for %q: %s", firstArg, err)
8887
absStartPath = filepath.Clean(firstArg)
8988
}
9089

@@ -117,13 +116,13 @@ func setupConfigFileSearch(args []string) {
117116
func getRelPath(p string) string {
118117
wd, err := os.Getwd()
119118
if err != nil {
120-
logutils.HiddenWarnf("Can't get wd: %s", err)
119+
logrus.Warnf("Can't get wd: %s", err)
121120
return p
122121
}
123122

124123
r, err := filepath.Rel(wd, p)
125124
if err != nil {
126-
logutils.HiddenWarnf("Can't make path %s relative to %s: %s", p, wd, err)
125+
logrus.Warnf("Can't make path %s relative to %s: %s", p, wd, err)
127126
return p
128127
}
129128

Diff for: pkg/golinters/gas.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"github.com/GoASTScanner/gas"
1212
"github.com/GoASTScanner/gas/rules"
1313
"github.com/golangci/golangci-lint/pkg/lint/linter"
14-
"github.com/golangci/golangci-lint/pkg/logutils"
1514
"github.com/golangci/golangci-lint/pkg/result"
15+
"github.com/sirupsen/logrus"
1616
)
1717

1818
type Gas struct{}
@@ -46,7 +46,7 @@ func (lint Gas) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issu
4646
if err != nil {
4747
r = &result.Range{}
4848
if n, rerr := fmt.Sscanf(i.Line, "%d-%d", &r.From, &r.To); rerr != nil || n != 2 {
49-
logutils.HiddenWarnf("Can't convert gas line number %q of %v to int: %s", i.Line, i, err)
49+
logrus.Warnf("Can't convert gas line number %q of %v to int: %s", i.Line, i, err)
5050
continue
5151
}
5252
line = r.From

Diff for: pkg/golinters/golint.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77
"go/token"
88

99
"github.com/golangci/golangci-lint/pkg/lint/linter"
10-
"github.com/golangci/golangci-lint/pkg/logutils"
1110
"github.com/golangci/golangci-lint/pkg/result"
1211
lintAPI "github.com/golangci/lint-1"
12+
"github.com/sirupsen/logrus"
1313
)
1414

1515
type Golint struct{}
@@ -39,7 +39,7 @@ func (g Golint) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issu
3939
issues = append(issues, i...)
4040
}
4141
if lintErr != nil {
42-
logutils.HiddenWarnf("golint: %s", lintErr)
42+
logrus.Warnf("golint: %s", lintErr)
4343
}
4444

4545
return issues, nil

Diff for: pkg/lint/astcache/astcache.go

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ func (c *Cache) parseFile(filePath string, fset *token.FileSet) {
108108
Err: err,
109109
Name: filePath,
110110
}
111+
if err != nil {
112+
logrus.Warnf("Can't parse AST of %s: %s", filePath, err)
113+
}
111114
}
112115

113116
func LoadFromFiles(files []string) (*Cache, error) {

Diff for: pkg/lint/runner.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"time"
1111

1212
"github.com/golangci/golangci-lint/pkg/lint/linter"
13-
"github.com/golangci/golangci-lint/pkg/logutils"
1413
"github.com/golangci/golangci-lint/pkg/result"
1514
"github.com/golangci/golangci-lint/pkg/result/processors"
1615
"github.com/golangci/golangci-lint/pkg/timeutils"
@@ -31,7 +30,7 @@ func runLinterSafe(ctx context.Context, lintCtx *linter.Context, lc linter.Confi
3130
defer func() {
3231
if panicData := recover(); panicData != nil {
3332
err = fmt.Errorf("panic occured: %s", panicData)
34-
logutils.HiddenWarnf("Panic stack trace: %s", debug.Stack())
33+
logrus.Warnf("Panic stack trace: %s", debug.Stack())
3534
}
3635
}()
3736

@@ -152,7 +151,7 @@ func (r SimpleRunner) processLintResults(ctx context.Context, inCh <-chan lintRe
152151

153152
for res := range inCh {
154153
if res.err != nil {
155-
logutils.HiddenWarnf("Can't run linter %s: %s", res.linter.Linter.Name(), res.err)
154+
logrus.Warnf("Can't run linter %s: %s", res.linter.Linter.Name(), res.err)
156155
continue
157156
}
158157

@@ -221,7 +220,7 @@ func (r *SimpleRunner) processIssues(ctx context.Context, issues []result.Issue,
221220
})
222221

223222
if err != nil {
224-
logutils.HiddenWarnf("Can't process result by %s processor: %s", p.Name(), err)
223+
logrus.Warnf("Can't process result by %s processor: %s", p.Name(), err)
225224
} else {
226225
issues = newIssues
227226
}

Diff for: pkg/logutils/logutils.go

-10
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ import (
77
"github.com/sirupsen/logrus"
88
)
99

10-
var isGolangCIRun = os.Getenv("GOLANGCI_COM_RUN") == "1"
11-
12-
func HiddenWarnf(format string, args ...interface{}) {
13-
if isGolangCIRun {
14-
logrus.Warnf(format, args...)
15-
} else {
16-
logrus.Infof(format, args...)
17-
}
18-
}
19-
2010
func getEnabledDebugs() map[string]bool {
2111
ret := map[string]bool{}
2212
debugVar := os.Getenv("GL_DEBUG")

0 commit comments

Comments
 (0)