Skip to content

Commit

Permalink
chore: enable early-return from revive
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 committed Jan 9, 2025
1 parent a1830b3 commit 4e5e126
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ linters-settings:
- name: context-keys-type
# Importing with `.` makes the programs much harder to understand
- name: dot-imports
- name: early-return
arguments:
- "preserveScope"
# Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring.
- name: empty-block
# for better readability, variables of type `error` must be named with the prefix `err`.
Expand All @@ -111,6 +114,8 @@ linters-settings:
- name: redefines-builtin-id
# redundant else-blocks that can be eliminated from the code.
- name: superfluous-else
arguments:
- "preserveScope"
# prevent confusing name for variables when using `time` package
- name: time-naming
# warns when an exported function or method returns a value of an un-exported type.
Expand Down
5 changes: 2 additions & 3 deletions internal/aws/metrics/metric_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ func NewFloat64DeltaCalculator() MetricCalculator {

func calculateDelta(prev *MetricValue, val any, _ time.Time) (any, bool) {
var deltaValue float64
if prev != nil {
deltaValue = val.(float64) - prev.RawValue.(float64)
} else {
if prev == nil {
return deltaValue, false
}
deltaValue = val.(float64) - prev.RawValue.(float64)
return deltaValue, true
}

Expand Down
5 changes: 2 additions & 3 deletions internal/sqlquery/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ func (s *Scraper) ScrapeMetrics(ctx context.Context) (pmetric.Metrics, error) {
out := pmetric.NewMetrics()
rows, err := s.Client.QueryRows(ctx)
if err != nil {
if errors.Is(err, ErrNullValueWarning) {
s.Logger.Warn("problems encountered getting metric rows", zap.Error(err))
} else {
if !errors.Is(err, ErrNullValueWarning) {
return out, fmt.Errorf("Scraper: %w", err)
}
s.Logger.Warn("problems encountered getting metric rows", zap.Error(err))
}
ts := pcommon.NewTimestampFromTime(time.Now())
rms := out.ResourceMetrics()
Expand Down

0 comments on commit 4e5e126

Please sign in to comment.