-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rename logrlint to loggercheck (#3144)
- Loading branch information
Showing
26 changed files
with
454 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package golinters | ||
|
||
import ( | ||
"github.com/timonwong/loggercheck" | ||
"golang.org/x/tools/go/analysis" | ||
|
||
"github.com/golangci/golangci-lint/pkg/config" | ||
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis" | ||
) | ||
|
||
func NewLoggerCheck(settings *config.LoggerCheckSettings) *goanalysis.Linter { | ||
var opts []loggercheck.Option | ||
|
||
if settings != nil { | ||
var disable []string | ||
if !settings.Kitlog { | ||
disable = append(disable, "kitlog") | ||
} | ||
if !settings.Klog { | ||
disable = append(disable, "klog") | ||
} | ||
if !settings.Logr { | ||
disable = append(disable, "logr") | ||
} | ||
if !settings.Zap { | ||
disable = append(disable, "zap") | ||
} | ||
|
||
opts = []loggercheck.Option{ | ||
loggercheck.WithDisable(disable), | ||
loggercheck.WithRequireStringKey(settings.RequireStringKey), | ||
loggercheck.WithRules(settings.Rules), | ||
loggercheck.WithNoPrintfLike(settings.NoPrintfLike), | ||
} | ||
} | ||
|
||
analyzer := loggercheck.NewAnalyzer(opts...) | ||
return goanalysis.NewLinter( | ||
analyzer.Name, | ||
analyzer.Doc, | ||
[]*analysis.Analyzer{analyzer}, | ||
nil, | ||
).WithLoadMode(goanalysis.LoadModeTypesInfo) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
linters-settings: | ||
loggercheck: | ||
rules: | ||
- (*command-line-arguments.Logger).Debugw | ||
- (*command-line-arguments.Logger).Infow | ||
- (*command-line-arguments.Logger).Warnw | ||
- (*command-line-arguments.Logger).Errorw | ||
- (*command-line-arguments.Logger).With | ||
- command-line-arguments.Debugw | ||
- command-line-arguments.Infow | ||
- command-line-arguments.Warnw | ||
- command-line-arguments.Errorw | ||
- command-line-arguments.With |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
linters-settings: | ||
loggercheck: | ||
kitlog: true | ||
klog: false | ||
logr: false | ||
zap: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
linters-settings: | ||
loggercheck: | ||
logr: true | ||
klog: false | ||
zap: false |
3 changes: 3 additions & 0 deletions
3
test/testdata/loggercheck/configs/loggercheck_noprintflike.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
linters-settings: | ||
loggercheck: | ||
no-printf-like: true |
3 changes: 3 additions & 0 deletions
3
test/testdata/loggercheck/configs/loggercheck_requirestringkey.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
linters-settings: | ||
loggercheck: | ||
require-string-key: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
linters-settings: | ||
loggercheck: | ||
logr: false | ||
klog: false | ||
zap: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module loggercheck | ||
|
||
go 1.19 | ||
|
||
require ( | ||
github.com/go-kit/log v0.2.1 | ||
github.com/go-logr/logr v1.2.3 | ||
go.uber.org/zap v1.23.0 | ||
k8s.io/klog/v2 v2.70.1 | ||
) | ||
|
||
require ( | ||
github.com/go-logfmt/logfmt v0.5.1 // indirect | ||
go.uber.org/atomic v1.10.0 // indirect | ||
go.uber.org/multierr v1.8.0 // indirect | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.