fixed linting config

This commit is contained in:
Stephan D
2026-02-12 13:00:37 +01:00
parent 97395acd8f
commit 7cbcbb4b3c
42 changed files with 1813 additions and 237 deletions

View File

@@ -1,4 +1,4 @@
package common
package common //nolint:revive // package provides shared market connector utilities
import (
"strconv"
@@ -8,39 +8,46 @@ import (
)
// DurationSetting reads a positive duration override from settings or returns def when the value is missing or invalid.
//
//nolint:cyclop
func DurationSetting(settings model.SettingsT, key string, def time.Duration) time.Duration {
if settings == nil {
return def
}
value, ok := settings[key]
if !ok {
return def
}
switch v := value.(type) {
switch val := value.(type) {
case time.Duration:
if v > 0 {
return v
if val > 0 {
return val
}
case int:
if v > 0 {
return time.Duration(v) * time.Second
if val > 0 {
return time.Duration(val) * time.Second
}
case int64:
if v > 0 {
return time.Duration(v) * time.Second
if val > 0 {
return time.Duration(val) * time.Second
}
case float64:
if v > 0 {
return time.Duration(v * float64(time.Second))
if val > 0 {
return time.Duration(val * float64(time.Second))
}
case string:
if parsed, err := time.ParseDuration(v); err == nil && parsed > 0 {
parsed, parseErr := time.ParseDuration(val)
if parseErr == nil && parsed > 0 {
return parsed
}
if seconds, err := strconv.ParseFloat(v, 64); err == nil && seconds > 0 {
seconds, floatErr := strconv.ParseFloat(val, 64)
if floatErr == nil && seconds > 0 {
return time.Duration(seconds * float64(time.Second))
}
}
return def
}