Compare commits
4 commits
master
...
lint-reviv
Author | SHA1 | Date | |
---|---|---|---|
|
09987ba4ce | ||
|
844dc7b384 | ||
|
e06a9a2666 | ||
|
c2d542983e |
3 changed files with 154 additions and 14 deletions
141
.golangci.yml
141
.golangci.yml
|
@ -118,6 +118,124 @@ linters-settings:
|
|||
- pkg: "gopkg.in/yaml.v2"
|
||||
desc: "yaml.v2 is deprecated for new code in favor of yaml.v3"
|
||||
|
||||
revive:
|
||||
ignore-generated-header: true
|
||||
severity: error
|
||||
enable-all-rules: true
|
||||
rules:
|
||||
- name: add-constant
|
||||
disabled: true
|
||||
- name: argument-limit
|
||||
disabled: true
|
||||
- name: bare-return
|
||||
disabled: true
|
||||
- name: blank-imports
|
||||
disabled: true
|
||||
- name: bool-literal-in-expr
|
||||
disabled: true
|
||||
- name: cognitive-complexity
|
||||
disabled: true
|
||||
- name: comment-spacings
|
||||
disabled: true
|
||||
- name: confusing-naming
|
||||
disabled: false
|
||||
- name: confusing-results
|
||||
disabled: true
|
||||
- name: context-as-argument
|
||||
disabled: true
|
||||
- name: cyclomatic
|
||||
disabled: true
|
||||
- name: deep-exit
|
||||
disabled: true
|
||||
- name: defer
|
||||
disabled: true
|
||||
- name: duplicated-imports
|
||||
disabled: true
|
||||
- name: early-return
|
||||
disabled: true
|
||||
- name: empty-block
|
||||
disabled: true
|
||||
- name: empty-lines
|
||||
disabled: true
|
||||
- name: error-naming
|
||||
disabled: true
|
||||
- name: error-strings
|
||||
disabled: true
|
||||
- name: flag-parameter
|
||||
disabled: true
|
||||
- name: function-result-limit
|
||||
disabled: true
|
||||
- name: function-length
|
||||
disabled: true
|
||||
- name: get-return
|
||||
disabled: true
|
||||
- name: if-return
|
||||
disabled: true
|
||||
- name: increment-decrement
|
||||
disabled: true
|
||||
- name: indent-error-flow
|
||||
disabled: true
|
||||
- name: import-alias-naming
|
||||
disabled: true
|
||||
- name: import-shadowing
|
||||
disabled: true
|
||||
- name: line-length-limit
|
||||
disabled: true
|
||||
- name: max-control-nesting
|
||||
disabled: true
|
||||
- name: max-public-structs
|
||||
disabled: true
|
||||
- name: modifies-parameter
|
||||
disabled: true
|
||||
- name: modifies-value-receiver
|
||||
disabled: false
|
||||
- name: optimize-operands-order
|
||||
disabled: true
|
||||
- name: nested-structs
|
||||
disabled: true
|
||||
- name: package-comments
|
||||
disabled: true
|
||||
- name: range-val-address
|
||||
disabled: false
|
||||
- name: redundant-import-alias
|
||||
disabled: true
|
||||
- name: struct-tag
|
||||
disabled: true
|
||||
- name: superfluous-else
|
||||
disabled: true
|
||||
- name: time-equal
|
||||
disabled: true
|
||||
- name: var-naming
|
||||
disabled: true
|
||||
- name: var-declaration
|
||||
disabled: true
|
||||
- name: unchecked-type-assertion
|
||||
disabled: true
|
||||
- name: exported
|
||||
disabled: true
|
||||
- name: unexported-naming
|
||||
disabled: true
|
||||
- name: unexported-return
|
||||
disabled: true
|
||||
- name: unhandled-error
|
||||
disabled: true
|
||||
arguments:
|
||||
- "fmt.Print"
|
||||
- "fmt.Printf"
|
||||
- "fmt.Println"
|
||||
- name: unnecessary-stmt
|
||||
disabled: true
|
||||
- name: unreachable-code
|
||||
disabled: true
|
||||
- name: unused-parameter
|
||||
disabled: true
|
||||
- name: unused-receiver
|
||||
disabled: true
|
||||
- name: use-any
|
||||
disabled: true
|
||||
- name: useless-break
|
||||
disabled: true
|
||||
|
||||
wsl:
|
||||
# Allow blocks to end with comments
|
||||
allow-trailing-comment: true
|
||||
|
@ -198,6 +316,7 @@ linters:
|
|||
# - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative.
|
||||
# - predeclared # find code that shadows one of Go's predeclared identifiers
|
||||
# - reassign # Checks that package variables are not reassigned
|
||||
# - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
|
||||
# - rowserrcheck # checks whether Rows.Err of rows is checked successfully
|
||||
# - sloglint # ensure consistent code style when using log/slog
|
||||
# - spancheck # Checks for mistakes with OpenTelemetry/Census spans.
|
||||
|
@ -229,7 +348,6 @@ linters:
|
|||
- musttag # enforce field tags in (un)marshaled structs
|
||||
- promlinter # Check Prometheus metrics naming via promlint
|
||||
- protogetter # Reports direct reads from proto message fields when getters should be used
|
||||
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
|
||||
- tagalign # check that struct tags are well aligned
|
||||
- thelper # thelper detects tests helpers which is not start with t.Helper() method.
|
||||
- wrapcheck # Checks that errors returned from external packages are wrapped
|
||||
|
@ -380,3 +498,24 @@ issues:
|
|||
- linters:
|
||||
- nonamedreturns
|
||||
text: "named return .* with type .* found"
|
||||
|
||||
- linters:
|
||||
- revive
|
||||
path: pkg/leakybucket/manager_load.go
|
||||
text: "confusing-naming: Field '.*' differs only by capitalization to other field in the struct type BucketFactory"
|
||||
|
||||
- linters:
|
||||
- revive
|
||||
path: pkg/exprhelpers/helpers.go
|
||||
text: "confusing-naming: Method 'flatten' differs only by capitalization to function 'Flatten' in the same source file"
|
||||
|
||||
- linters:
|
||||
- revive
|
||||
path: pkg/appsec/query_utils.go
|
||||
text: "confusing-naming: Method 'parseQuery' differs only by capitalization to function 'ParseQuery' in the same source file"
|
||||
|
||||
- linters:
|
||||
- revive
|
||||
path: pkg/acquisition/modules/loki/internal/lokiclient/loki_client.go
|
||||
text: "confusing-naming: Method 'QueryRange' differs only by capitalization to method 'queryRange' in the same source file"
|
||||
|
||||
|
|
|
@ -26,11 +26,12 @@ func dedupAlerts(alerts []types.RuntimeAlert) ([]*models.Alert, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
for k, src := range alert.Sources {
|
||||
for k := range alert.Sources {
|
||||
refsrc := *alert.Alert // copy
|
||||
|
||||
log.Tracef("source[%s]", k)
|
||||
|
||||
src := alert.Sources[k]
|
||||
refsrc.Source = &src
|
||||
dedupCache = append(dedupCache, &refsrc)
|
||||
}
|
||||
|
|
|
@ -121,14 +121,14 @@ type crzLogger struct {
|
|||
logLevel log.Level
|
||||
}
|
||||
|
||||
func NewCrzLogger(logger *log.Entry) crzLogger {
|
||||
return crzLogger{logger: logger, logLevel: logger.Logger.GetLevel()}
|
||||
func NewCrzLogger(logger *log.Entry) *crzLogger {
|
||||
return &crzLogger{logger: logger, logLevel: logger.Logger.GetLevel()}
|
||||
}
|
||||
|
||||
func (c crzLogger) NewMutedEvt(lvl log.Level) dbg.Event {
|
||||
func (c *crzLogger) NewMutedEvt(lvl log.Level) dbg.Event {
|
||||
return &crzLogEvent{muted: true, logger: c.logger, level: lvl}
|
||||
}
|
||||
func (c crzLogger) NewEvt(lvl log.Level) dbg.Event {
|
||||
func (c *crzLogger) NewEvt(lvl log.Level) dbg.Event {
|
||||
evt := &crzLogEvent{fields: map[string]interface{}{}, logger: c.logger, level: lvl}
|
||||
if c.defaultFields != nil {
|
||||
for k, v := range c.defaultFields {
|
||||
|
@ -138,17 +138,17 @@ func (c crzLogger) NewEvt(lvl log.Level) dbg.Event {
|
|||
return evt
|
||||
}
|
||||
|
||||
func (c crzLogger) WithOutput(w io.Writer) dbg.Logger {
|
||||
func (c *crzLogger) WithOutput(w io.Writer) dbg.Logger {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c crzLogger) WithLevel(lvl dbg.Level) dbg.Logger {
|
||||
func (c *crzLogger) WithLevel(lvl dbg.Level) dbg.Logger {
|
||||
c.logLevel = log.Level(lvl)
|
||||
c.logger.Logger.SetLevel(c.logLevel)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c crzLogger) With(fs ...dbg.ContextField) dbg.Logger {
|
||||
func (c *crzLogger) With(fs ...dbg.ContextField) dbg.Logger {
|
||||
var e dbg.Event = c.NewEvt(c.logLevel)
|
||||
for _, f := range fs {
|
||||
e = f(e)
|
||||
|
@ -157,14 +157,14 @@ func (c crzLogger) With(fs ...dbg.ContextField) dbg.Logger {
|
|||
return c
|
||||
}
|
||||
|
||||
func (c crzLogger) Trace() dbg.Event {
|
||||
func (c *crzLogger) Trace() dbg.Event {
|
||||
if c.logLevel < log.TraceLevel {
|
||||
return c.NewMutedEvt(log.TraceLevel)
|
||||
}
|
||||
return c.NewEvt(log.TraceLevel)
|
||||
}
|
||||
|
||||
func (c crzLogger) Debug() dbg.Event {
|
||||
func (c *crzLogger) Debug() dbg.Event {
|
||||
if c.logLevel < log.DebugLevel {
|
||||
return c.NewMutedEvt(log.DebugLevel)
|
||||
|
||||
|
@ -172,21 +172,21 @@ func (c crzLogger) Debug() dbg.Event {
|
|||
return c.NewEvt(log.DebugLevel)
|
||||
}
|
||||
|
||||
func (c crzLogger) Info() dbg.Event {
|
||||
func (c *crzLogger) Info() dbg.Event {
|
||||
if c.logLevel < log.InfoLevel {
|
||||
return c.NewMutedEvt(log.InfoLevel)
|
||||
}
|
||||
return c.NewEvt(log.InfoLevel)
|
||||
}
|
||||
|
||||
func (c crzLogger) Warn() dbg.Event {
|
||||
func (c *crzLogger) Warn() dbg.Event {
|
||||
if c.logLevel < log.WarnLevel {
|
||||
return c.NewMutedEvt(log.WarnLevel)
|
||||
}
|
||||
return c.NewEvt(log.WarnLevel)
|
||||
}
|
||||
|
||||
func (c crzLogger) Error() dbg.Event {
|
||||
func (c *crzLogger) Error() dbg.Event {
|
||||
if c.logLevel < log.ErrorLevel {
|
||||
return c.NewMutedEvt(log.ErrorLevel)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue