Skip to content

Commit 6a79b84

Browse files
committed
Several code cleanups prompted by golangci-lint
Signed-off-by: Bryan Boreham <[email protected]>
1 parent 9d7a794 commit 6a79b84

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

pkg/configs/configs.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,8 @@ func (c RulesConfig) parseV2Formatted() (map[string]rulefmt.RuleGroups, error) {
203203

204204
for fn, content := range c.Files {
205205
rgs, errs := rulefmt.Parse([]byte(content))
206-
if errs != nil {
207-
for _, err := range errs {
208-
return nil, err
209-
}
206+
for _, err := range errs { // return just the first error, if any
207+
return nil, err
210208
}
211209
ruleMap[fn] = *rgs
212210

pkg/cortex/modules.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ func (t *Cortex) initQueryFrontend(cfg *Config) (err error) {
312312
func (t *Cortex) stopQueryFrontend() (err error) {
313313
t.frontend.Close()
314314
if t.cache != nil {
315-
t.cache.Stop()
315+
_ = t.cache.Stop()
316316
t.cache = nil
317317
}
318318
return

pkg/ingester/ingester_v2.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,14 @@ func (i *Ingester) getOrCreateTSDB(userID string, force bool) (*tsdb.DB, error)
407407
i.done.Add(1)
408408
go func() {
409409
defer i.done.Done()
410-
runutil.Repeat(i.cfg.TSDBConfig.ShipInterval, i.quit, func() error {
410+
if err := runutil.Repeat(i.cfg.TSDBConfig.ShipInterval, i.quit, func() error {
411411
if uploaded, err := s.Sync(context.Background()); err != nil {
412412
level.Warn(util.Logger).Log("err", err, "uploaded", uploaded)
413413
}
414414
return nil
415-
})
415+
}); err != nil {
416+
level.Warn(util.Logger).Log("err", err)
417+
}
416418
}()
417419

418420
i.TSDBState.dbs[userID] = db

pkg/ring/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (i *IngesterDesc) IsHealthy(op Operation, heartbeatTimeout time.Duration) b
171171
healthy = true
172172
}
173173

174-
return healthy && time.Now().Sub(time.Unix(i.Timestamp, 0)) <= heartbeatTimeout
174+
return healthy && time.Since(time.Unix(i.Timestamp, 0)) <= heartbeatTimeout
175175
}
176176

177177
// Merge merges other ring into this one. Returns sub-ring that represents the change,

pkg/util/limiter/rate_limiter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (l *RateLimiter) recheckTenantLimiter(now time.Time, tenantID string) *rate
9999
l.tenantsLock.Lock()
100100
defer l.tenantsLock.Unlock()
101101

102-
entry, _ := l.tenants[tenantID]
102+
entry := l.tenants[tenantID]
103103

104104
// We check again if the recheck period elapsed, cause it may
105105
// have already been rechecked in the meanwhile.

0 commit comments

Comments
 (0)