mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 04:15:54 +02:00
lint: enable errcheck; add allowlist and explicit checks (#3403)
* lint: enable errcheck with explicit allow list * add explicit error checks * windows tests * windows nolint
This commit is contained in:
parent
fe931af5ca
commit
49fb24c3b1
13 changed files with 112 additions and 52 deletions
|
@ -29,8 +29,6 @@ import (
|
|||
"github.com/umahmood/haversine"
|
||||
"github.com/wasilibs/go-re2"
|
||||
|
||||
"github.com/crowdsecurity/go-cs-lib/ptr"
|
||||
|
||||
"github.com/crowdsecurity/crowdsec/pkg/cache"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/database"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/fflag"
|
||||
|
@ -146,17 +144,19 @@ func RegexpCacheInit(filename string, cacheCfg types.DataSource) error {
|
|||
}
|
||||
// cache is enabled
|
||||
|
||||
if cacheCfg.Size == nil {
|
||||
cacheCfg.Size = ptr.Of(50)
|
||||
size := 50
|
||||
if cacheCfg.Size != nil {
|
||||
size = *cacheCfg.Size
|
||||
}
|
||||
|
||||
gc := gcache.New(*cacheCfg.Size)
|
||||
gc := gcache.New(size)
|
||||
|
||||
if cacheCfg.Strategy == nil {
|
||||
cacheCfg.Strategy = ptr.Of("LRU")
|
||||
strategy := "LRU"
|
||||
if cacheCfg.Strategy != nil {
|
||||
strategy = *cacheCfg.Strategy
|
||||
}
|
||||
|
||||
switch *cacheCfg.Strategy {
|
||||
switch strategy {
|
||||
case "LRU":
|
||||
gc = gc.LRU()
|
||||
case "LFU":
|
||||
|
@ -164,7 +164,7 @@ func RegexpCacheInit(filename string, cacheCfg types.DataSource) error {
|
|||
case "ARC":
|
||||
gc = gc.ARC()
|
||||
default:
|
||||
return fmt.Errorf("unknown cache strategy '%s'", *cacheCfg.Strategy)
|
||||
return fmt.Errorf("unknown cache strategy '%s'", strategy)
|
||||
}
|
||||
|
||||
if cacheCfg.TTL != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue