mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-10 20:05:55 +02:00
lint/refactor: defer, reflectvaluecompare, stylecheck (#3544)
* lint: enable reflectvaluecompare * lint: remove exception * lint: stylecheck ST016 - methods on the same type should have the same receiver name * lint: enable revive[time-equal]
This commit is contained in:
parent
48e3c8c5d4
commit
faa5b482f6
4 changed files with 7 additions and 17 deletions
|
@ -183,7 +183,6 @@ linters:
|
|||
|
||||
govet:
|
||||
disable:
|
||||
- reflectvaluecompare
|
||||
- fieldalignment
|
||||
enable-all: true
|
||||
|
||||
|
@ -269,8 +268,6 @@ linters:
|
|||
disabled: true
|
||||
- name: redundant-import-alias
|
||||
disabled: true
|
||||
- name: time-equal
|
||||
disabled: true
|
||||
- name: var-naming
|
||||
disabled: true
|
||||
- name: unchecked-type-assertion
|
||||
|
@ -304,7 +301,6 @@ linters:
|
|||
- -ST1003
|
||||
- -ST1005
|
||||
- -ST1012
|
||||
- -ST1016
|
||||
- -ST1022
|
||||
- -QF1003
|
||||
- -QF1008
|
||||
|
@ -379,11 +375,6 @@ linters:
|
|||
path: pkg/acquisition/modules/victorialogs/internal/vlclient/vl_client.go
|
||||
text: 'confusing-naming: Method ''QueryRange'' differs only by capitalization to method ''queryRange'' in the same source file'
|
||||
|
||||
- linters:
|
||||
- revive
|
||||
path: pkg/hubtest/hubtest_item.go
|
||||
text: 'cyclomatic: .*RunWithLogFile'
|
||||
|
||||
# tolerate complex functions in tests for now
|
||||
- linters:
|
||||
- maintidx
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||
)
|
||||
|
||||
//nolint:deadcode,unused // debugHandler is kept as a dev convenience: it shuts down and serialize internal state
|
||||
//nolint:unused // debugHandler is kept as a dev convenience: it shuts down and serialize internal state
|
||||
func debugHandler(sig os.Signal, cConfig *csconfig.Config) error {
|
||||
var (
|
||||
tmpFile string
|
||||
|
|
|
@ -48,12 +48,12 @@ type ApiClient struct {
|
|||
UsageMetrics *UsageMetricsService
|
||||
}
|
||||
|
||||
func (a *ApiClient) GetClient() *http.Client {
|
||||
return a.client
|
||||
func (c *ApiClient) GetClient() *http.Client {
|
||||
return c.client
|
||||
}
|
||||
|
||||
func (a *ApiClient) IsEnrolled() bool {
|
||||
jwtTransport := a.client.Transport.(*JWTTransport)
|
||||
func (c *ApiClient) IsEnrolled() bool {
|
||||
jwtTransport := c.client.Transport.(*JWTTransport)
|
||||
tokenStr := jwtTransport.Token
|
||||
|
||||
token, _ := jwt.Parse(tokenStr, nil)
|
||||
|
|
|
@ -42,9 +42,8 @@ func SetTargetByName(target string, value string, evt *types.Event) bool {
|
|||
}()
|
||||
|
||||
iter := reflect.ValueOf(evt).Elem()
|
||||
if (iter == reflect.Value{}) || iter.IsZero() {
|
||||
if !iter.IsValid() || iter.IsZero() {
|
||||
log.Tracef("event is nil")
|
||||
//event is nil
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -56,7 +55,7 @@ func SetTargetByName(target string, value string, evt *types.Event) bool {
|
|||
case reflect.Map:
|
||||
tmp := iter.MapIndex(reflect.ValueOf(f))
|
||||
/*if we're in a map and the field doesn't exist, the user wants to add it :) */
|
||||
if (tmp == reflect.Value{}) || tmp.IsZero() {
|
||||
if !tmp.IsValid() || tmp.IsZero() {
|
||||
log.Debugf("map entry is zero in '%s'", target)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue