@@ -40,8 +40,8 @@ import (
4040
4141 "github.com/dustin/go-humanize"
4242 "github.com/jinzhu/gorm"
43- _ "github.com/jinzhu/gorm/dialects/mysql"
44- _ "github.com/jinzhu/gorm/dialects/sqlite"
43+ _ "github.com/jinzhu/gorm/dialects/mysql" // register mysql dialect
44+ _ "github.com/jinzhu/gorm/dialects/sqlite" // register sqlite dialect
4545 "github.com/klauspost/cpuid/v2"
4646 gc "github.com/patrickmn/go-cache"
4747 "github.com/pbnjay/memory"
@@ -69,7 +69,6 @@ import (
6969
7070// Config aggregates CLI flags, options.yml overrides, runtime settings, and shared resources (database, caches) for the running instance.
7171type Config struct {
72- once sync.Once
7372 cliCtx * cli.Context
7473 options * Options
7574 settings * customize.Settings
@@ -135,13 +134,14 @@ func initLogger() {
135134 FullTimestamp : true ,
136135 })
137136
138- if Env (EnvProd ) {
137+ switch {
138+ case Env (EnvProd ):
139139 SetLogLevel (logrus .WarnLevel )
140- } else if Env (EnvTrace ) {
140+ case Env (EnvTrace ):
141141 SetLogLevel (logrus .TraceLevel )
142- } else if Env (EnvDebug ) {
142+ case Env (EnvDebug ):
143143 SetLogLevel (logrus .DebugLevel )
144- } else {
144+ default :
145145 SetLogLevel (logrus .InfoLevel )
146146 }
147147 })
@@ -239,7 +239,7 @@ func (c *Config) Init() error {
239239 // Configure HTTPS proxy for outgoing connections.
240240 if httpsProxy := c .HttpsProxy (); httpsProxy != "" {
241241 http .DefaultTransport .(* http.Transport ).TLSClientConfig = & tls.Config {
242- InsecureSkipVerify : c .HttpsProxyInsecure (),
242+ InsecureSkipVerify : c .HttpsProxyInsecure (), //nolint:gosec // proxy settings are user-configurable and opt-in
243243 }
244244
245245 _ = os .Setenv ("HTTPS_PROXY" , httpsProxy )
@@ -454,15 +454,15 @@ func (c *Config) readSerial() string {
454454 backupName := c .BackupPath (serialName )
455455
456456 if fs .FileExists (storageName ) {
457- if data , err := os .ReadFile (storageName ); err == nil && len (data ) == 16 {
457+ if data , err := os .ReadFile (storageName ); err == nil && len (data ) == 16 { //nolint:gosec // path is computed from config storage
458458 return string (data )
459459 } else {
460460 log .Tracef ("config: could not read %s (%s)" , clean .Log (storageName ), err )
461461 }
462462 }
463463
464464 if fs .FileExists (backupName ) {
465- if data , err := os .ReadFile (backupName ); err == nil && len (data ) == 16 {
465+ if data , err := os .ReadFile (backupName ); err == nil && len (data ) == 16 { //nolint:gosec // backup file path is generated internally
466466 return string (data )
467467 } else {
468468 log .Tracef ("config: could not read %s (%s)" , clean .Log (backupName ), err )
@@ -729,7 +729,7 @@ func (c *Config) WakeupInterval() time.Duration {
729729 if c .options .WakeupInterval < MinWakeupInterval / time .Second {
730730 return MinWakeupInterval
731731 } else if c .options .WakeupInterval < MinWakeupInterval {
732- c .options .WakeupInterval = c . options . WakeupInterval * time .Second
732+ c .options .WakeupInterval *= time .Second
733733 }
734734
735735 // Do not run less than once per day.
@@ -786,11 +786,12 @@ func (c *Config) ResolutionLimit() int {
786786
787787 // Disabling or increasing the limit is at your own risk.
788788 // Only sponsors receive support in case of problems.
789- if result == 0 {
789+ switch {
790+ case result == 0 :
790791 return DefaultResolutionLimit
791- } else if result < 0 {
792+ case result < 0 :
792793 return - 1
793- } else if result > 900 {
794+ case result > 900 :
794795 result = 900
795796 }
796797
@@ -857,7 +858,7 @@ func (c *Config) initHub() {
857858 c .hubCancel = cancel
858859 c .hubLock .Unlock ()
859860
860- d := 23 * time .Hour + time .Duration (float64 (2 * time .Hour )* rand .Float64 ())
861+ d := 23 * time .Hour + time .Duration (float64 (2 * time .Hour )* rand .Float64 ()) //nolint:gosec // jitter for scheduling only, crypto not required
861862 ticker := time .NewTicker (d )
862863
863864 go func () {
0 commit comments