From 8f67dd3b08fb505b3457975a9b30b43fe07ab718 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 11 Mar 2021 09:38:10 +0100 Subject: [PATCH] fix sonar smells --- ocis/pkg/runtime/service/service.go | 4 +-- proxy/pkg/metrics/metrics.go | 14 +++------ storage/pkg/command/options.go | 47 ----------------------------- 3 files changed, 6 insertions(+), 59 deletions(-) delete mode 100644 storage/pkg/command/options.go diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index eb7e857417..d15c23937f 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -253,7 +253,7 @@ func trap(s *Service, halt chan os.Signal) { for sName := range s.serviceToken { for i := range s.serviceToken[sName] { if err := s.Supervisor.Remove(s.serviceToken[sName][i]); err != nil { - // TODO(refs) deal with me + s.Log.Error().Err(err).Str("service", "runtime service").Msgf("terminating with signal: %v", s) } } } @@ -265,7 +265,7 @@ func trap(s *Service, halt chan os.Signal) { // want to expose to the end user the internal framework logs unless explicitly specified. func setMicroLogger() { if os.Getenv("MICRO_LOG_LEVEL") == "" { - os.Setenv("MICRO_LOG_LEVEL", "error") + _ = os.Setenv("MICRO_LOG_LEVEL", "error") } lev, err := zerolog.ParseLevel(os.Getenv("MICRO_LOG_LEVEL")) diff --git a/proxy/pkg/metrics/metrics.go b/proxy/pkg/metrics/metrics.go index d3cb55f750..a14e949252 100644 --- a/proxy/pkg/metrics/metrics.go +++ b/proxy/pkg/metrics/metrics.go @@ -49,15 +49,9 @@ func New() *Metrics { }, []string{"versions"}), } - prometheus.Register(m.Counter) - prometheus.Register(m.Latency) - prometheus.Register(m.Duration) - prometheus.Register(m.BuildInfo) + _ = prometheus.Register(m.Counter) + _ = prometheus.Register(m.Latency) + _ = prometheus.Register(m.Duration) + _ = prometheus.Register(m.BuildInfo) return m } - -func mustNotFail(err error) { - if err != nil { - panic(err) - } -} diff --git a/storage/pkg/command/options.go b/storage/pkg/command/options.go deleted file mode 100644 index e9e4467de4..0000000000 --- a/storage/pkg/command/options.go +++ /dev/null @@ -1,47 +0,0 @@ -package command - -// Option defines a single modifier to an Options attribute. -type Option func(o *Options) - -type Options struct { - // LogPretty toggles pretty logging lines. - LogPretty bool - - // LogColor toggles colored output. - LogColor bool - - // LogLevel raises / decreases logging levels. - LogLevel string -} - -// newOptions initializes the available default options. -func newOptions(opts ...Option) Options { - opt := Options{} - - for _, o := range opts { - o(&opt) - } - - return opt -} - -// WithLogPretty toggles pretty output for a storage logger. -func WithLogPretty(v bool) Option { - return func(o *Options) { - o.LogPretty = v - } -} - -// WithLogColor toggles colored output for a storage logger. -func WithLogColor(v bool) Option { - return func(o *Options) { - o.LogColor = v - } -} - -// WithLogLevel toggles colored output for a storage logger. -func WithLogLevel(v string) Option { - return func(o *Options) { - o.LogLevel = v - } -}