Skip to content

Commit

Permalink
[chore] remove redundant ifs (#22916)
Browse files Browse the repository at this point in the history
Linked issue: #20424

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
Alex Boten authored May 30, 2023
1 parent 7be4a23 commit f20113f
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 50 deletions.
5 changes: 1 addition & 4 deletions exporter/clickhouseexporter/exporter_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ func (e *logsExporter) start(ctx context.Context, _ component.Host) error {
return err
}

if err := createLogsTable(ctx, e.cfg, e.client); err != nil {
return err
}
return nil
return createLogsTable(ctx, e.cfg, e.client)
}

// shutdown will shut down the exporter.
Expand Down
5 changes: 1 addition & 4 deletions exporter/clickhouseexporter/exporter_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ func (e *metricsExporter) start(ctx context.Context, _ component.Host) error {
}

internal.SetLogger(e.logger)
if err := internal.NewMetricsTable(ctx, e.cfg.MetricsTableName, e.cfg.TTLDays, e.client); err != nil {
return err
}
return nil
return internal.NewMetricsTable(ctx, e.cfg.MetricsTableName, e.cfg.TTLDays, e.client)
}

// shutdown will shut down the exporter.
Expand Down
5 changes: 1 addition & 4 deletions exporter/clickhouseexporter/exporter_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ func (e *tracesExporter) start(ctx context.Context, _ component.Host) error {
return err
}

if err := createTracesTable(ctx, e.cfg, e.client); err != nil {
return err
}
return nil
return createTracesTable(ctx, e.cfg, e.client)
}

// shutdown will shut down the exporter.
Expand Down
5 changes: 1 addition & 4 deletions exporter/datadogexporter/internal/logs/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ func (s *Sender) SubmitLogs(ctx context.Context, payload []datadogV2.HTTPLogItem
batch = []datadogV2.HTTPLogItem{p}
prevtags = tags
}
if err := s.handleSubmitLog(ctx, batch, tags); err != nil {
return err
}
return nil
return s.handleSubmitLog(ctx, batch, tags)
}

func (s *Sender) handleSubmitLog(ctx context.Context, batch []datadogV2.HTTPLogItem, tags string) error {
Expand Down
6 changes: 1 addition & 5 deletions exporter/fileexporter/file_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,8 @@ func exportMessageAsBuffer(e *fileExporter, buf []byte) error {
// each encoded object is preceded by 4 bytes (an unsigned 32 bit integer)
data := make([]byte, 4, 4+len(buf))
binary.BigEndian.PutUint32(data, uint32(len(buf)))
data = append(data, buf...)
if err := binary.Write(e.file, binary.BigEndian, data); err != nil {
return err
}

return nil
return binary.Write(e.file, binary.BigEndian, append(data, buf...))
}

// startFlusher starts the flusher.
Expand Down
9 changes: 2 additions & 7 deletions exporter/mezmoexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func newLogsExporter(config *Config, settings component.TelemetrySettings, build
return e
}

func (m *mezmoExporter) pushLogData(ctx context.Context, ld plog.Logs) error {
func (m *mezmoExporter) pushLogData(_ context.Context, ld plog.Logs) error {
m.wg.Add(1)
defer m.wg.Done()

Expand Down Expand Up @@ -158,12 +158,7 @@ func (m *mezmoExporter) logDataToMezmo(ld plog.Logs) error {
}
}

str := b.String() + "]}"
if errs = m.sendLinesToMezmo(str); errs != nil {
return errs
}

return nil
return m.sendLinesToMezmo(b.String() + "]}")
}

func (m *mezmoExporter) sendLinesToMezmo(post string) (errs error) {
Expand Down
5 changes: 1 addition & 4 deletions extension/storage/dbstorage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,5 @@ func (c *dbStorageClient) Close(_ context.Context) error {
if err := c.deleteQuery.Close(); err != nil {
return err
}
if err := c.getQuery.Close(); err != nil {
return err
}
return nil
return c.getQuery.Close()
}
5 changes: 1 addition & 4 deletions internal/coreinternal/golden/golden.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ func writeMetrics(filePath string, metrics pmetric.Metrics) error {
if err != nil {
return err
}
if err := os.WriteFile(filePath, b, 0600); err != nil {
return err
}
return nil
return os.WriteFile(filePath, b, 0600)
}

// ReadLogs reads a plog.Logs from the specified YAML or JSON file.
Expand Down
5 changes: 1 addition & 4 deletions receiver/awsfirehosereceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,5 @@ func (c *Config) Validate() error {
if c.RecordType == "" {
return errors.New("must specify record type")
}
if err := validateRecordType(c.RecordType); err != nil {
return err
}
return nil
return validateRecordType(c.RecordType)
}
5 changes: 1 addition & 4 deletions receiver/prometheusreceiver/metrics_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ func (r *pReceiver) applyCfg(cfg *config.Config) error {
discoveryCfg[scrapeConfig.JobName] = scrapeConfig.ServiceDiscoveryConfigs
r.settings.Logger.Info("Scrape job added", zap.String("jobName", scrapeConfig.JobName))
}
if err := r.discoveryManager.ApplyConfig(discoveryCfg); err != nil {
return err
}
return nil
return r.discoveryManager.ApplyConfig(discoveryCfg)
}

func (r *pReceiver) initPrometheusComponents(ctx context.Context, host component.Host, logger log.Logger) error {
Expand Down
7 changes: 1 addition & 6 deletions receiver/statsdreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,5 @@ func (r *statsdReceiver) Shutdown(context.Context) error {
}

func (r *statsdReceiver) Flush(ctx context.Context, metrics pmetric.Metrics, nextConsumer consumer.Metrics) error {
error := nextConsumer.ConsumeMetrics(ctx, metrics)
if error != nil {
return error
}

return nil
return nextConsumer.ConsumeMetrics(ctx, metrics)
}

0 comments on commit f20113f

Please sign in to comment.