diff --git a/.golangci.yml b/.golangci.yml index 42d441eb75cd..dfb29bf1f9c2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -149,6 +149,7 @@ linters: - unconvert - unparam - unused + - wastedassign issues: # Excluding configuration per-path, per-linter, per-text and per-source diff --git a/exporter/dynatraceexporter/internal/serialization/histogram.go b/exporter/dynatraceexporter/internal/serialization/histogram.go index eba3b938dc0f..5b752a39765d 100644 --- a/exporter/dynatraceexporter/internal/serialization/histogram.go +++ b/exporter/dynatraceexporter/internal/serialization/histogram.go @@ -160,7 +160,7 @@ func histDataPointToSummary(dp pmetric.HistogramDataPoint) (float64, float64, fl } func estimateSingleBucketHistogram(dp pmetric.HistogramDataPoint) (float64, float64, float64) { - min, max, sum := 0.0, 0.0, 0.0 + var min, max, sum float64 if dp.HasSum() { sum = dp.Sum() diff --git a/exporter/prometheusremotewriteexporter/wal.go b/exporter/prometheusremotewriteexporter/wal.go index d53e8688ec24..746ba53bff26 100644 --- a/exporter/prometheusremotewriteexporter/wal.go +++ b/exporter/prometheusremotewriteexporter/wal.go @@ -227,7 +227,7 @@ func (prwe *prweWAL) continuallyPopWALThenExport(ctx context.Context, signalStar } reqL = append(reqL, req) - shouldExport := false + var shouldExport bool select { case <-timer.C: shouldExport = true diff --git a/exporter/sumologicexporter/exporter.go b/exporter/sumologicexporter/exporter.go index 58b3aee00def..398ed8a02a6a 100644 --- a/exporter/sumologicexporter/exporter.go +++ b/exporter/sumologicexporter/exporter.go @@ -140,7 +140,7 @@ func (se *sumologicexporter) start(_ context.Context, host component.Host) (err // so they can be handled by OTC retry mechanism func (se *sumologicexporter) pushLogsData(ctx context.Context, ld plog.Logs) error { var ( - currentMetadata = newFields(pcommon.NewMap()) + currentMetadata fields previousMetadata = newFields(pcommon.NewMap()) errs error droppedRecords []plog.LogRecord @@ -233,7 +233,7 @@ func (se *sumologicexporter) pushLogsData(ctx context.Context, ld plog.Logs) err // so they can be handle by the OTC retry mechanism func (se *sumologicexporter) pushMetricsData(ctx context.Context, md pmetric.Metrics) error { var ( - currentMetadata = newFields(pcommon.NewMap()) + currentMetadata fields previousMetadata = newFields(pcommon.NewMap()) errs error droppedRecords []metricPair diff --git a/pkg/ottl/contexts/internal/value.go b/pkg/ottl/contexts/internal/value.go index addfdf5c536c..1ac4e322b98a 100644 --- a/pkg/ottl/contexts/internal/value.go +++ b/pkg/ottl/contexts/internal/value.go @@ -71,7 +71,8 @@ func SetValue(value pcommon.Value, val interface{}) error { } func getIndexableValue(value pcommon.Value, keys []ottl.Key) (any, error) { - val, ok := value, false + val := value + var ok bool for i := 0; i < len(keys); i++ { switch val.Type() { case pcommon.ValueTypeMap: diff --git a/receiver/mongodbatlasreceiver/logs.go b/receiver/mongodbatlasreceiver/logs.go index 4635f6e82ee8..1a69e5e4a8d3 100644 --- a/receiver/mongodbatlasreceiver/logs.go +++ b/receiver/mongodbatlasreceiver/logs.go @@ -169,7 +169,7 @@ func (s *logsReceiver) collectClusterLogs(clusters []mongodbatlas.Cluster, proje func filterClusters(clusters []mongodbatlas.Cluster, projectCfg ProjectConfig) ([]mongodbatlas.Cluster, error) { include, exclude := projectCfg.IncludeClusters, projectCfg.ExcludeClusters - whitelist := false + var allowed bool var clusterNameSet map[string]struct{} // check to include or exclude clusters switch { @@ -178,11 +178,11 @@ func filterClusters(clusters []mongodbatlas.Cluster, projectCfg ProjectConfig) ( return clusters, nil // include is initialized case len(include) > 0 && len(exclude) == 0: - whitelist = true + allowed = true clusterNameSet = projectCfg.includesByClusterName // exclude is initialized case len(exclude) > 0 && len(include) == 0: - whitelist = false + allowed = false clusterNameSet = projectCfg.excludesByClusterName // both are initialized default: @@ -191,7 +191,7 @@ func filterClusters(clusters []mongodbatlas.Cluster, projectCfg ProjectConfig) ( var filtered []mongodbatlas.Cluster for _, cluster := range clusters { - if _, ok := clusterNameSet[cluster.Name]; (!ok && !whitelist) || (ok && whitelist) { + if _, ok := clusterNameSet[cluster.Name]; (!ok && !allowed) || (ok && allowed) { filtered = append(filtered, cluster) } } diff --git a/receiver/prometheusreceiver/internal/metricfamily.go b/receiver/prometheusreceiver/internal/metricfamily.go index 18fa97f7618e..e501ee5da384 100644 --- a/receiver/prometheusreceiver/internal/metricfamily.go +++ b/receiver/prometheusreceiver/internal/metricfamily.go @@ -322,7 +322,7 @@ func (mf *metricFamily) appendMetric(metrics pmetric.MetricSlice, trimSuffixes b metric.SetDescription(mf.metadata.Help) metric.SetUnit(prometheus.UnitWordToUCUM(mf.metadata.Unit)) - pointCount := 0 + var pointCount int switch mf.mtype { case pmetric.MetricTypeHistogram: diff --git a/receiver/prometheusreceiver/internal/util.go b/receiver/prometheusreceiver/internal/util.go index 60312df18a32..405a181f47a5 100644 --- a/receiver/prometheusreceiver/internal/util.go +++ b/receiver/prometheusreceiver/internal/util.go @@ -74,7 +74,7 @@ func timestampFromMs(timeAtMs int64) pcommon.Timestamp { } func getBoundary(metricType pmetric.MetricType, labels labels.Labels) (float64, error) { - val := "" + var val string switch metricType { case pmetric.MetricTypeHistogram: val = labels.Get(model.BucketLabel)