-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: rename logrlint to loggercheck #3144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6b21235
feat: rename logrlint to loggercheck
timonwong a11d085
revert package rename
timonwong 07a312f
rename logrlint to loggercheck
timonwong 9530cb5
Add comments for settings
timonwong d430ac5
fix tests
timonwong 4f1b535
review
ldez 9fe4e63
review
ldez a8b6e34
bump loggercheck; allow custom rules
timonwong dd0877d
disable zap by default timonwong/loggercheck#27
timonwong 1d8bf31
fix doc for rules
timonwong 76d6170
add support to require logging key as strings
timonwong d458aa8
add support to go-kit/log
timonwong 34c05e2
re-enable kitlog and zap by default
timonwong e9c8fe4
bump loggercheck; add support to no-printf-like
timonwong 82e647e
add custom rules example
timonwong cea6d9e
loggercheck version bump
timonwong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.