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:
mmetc 2025-01-16 16:13:10 +01:00 committed by GitHub
parent fe931af5ca
commit 49fb24c3b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 112 additions and 52 deletions

View file

@ -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 {