From 62445848e265fcaf7dc966fa2aff1b472d548390 Mon Sep 17 00:00:00 2001 From: SuperQ Date: Thu, 6 Jul 2023 09:41:04 +0200 Subject: [PATCH] Improve linting * Disable unused-parameter check due to false positives on Collect() calls. * Enable misspell. * Simplify error returns. Signed-off-by: SuperQ --- .golangci.yml | 7 +++++++ collector/pg_database.go | 5 +---- collector/pg_replication_slot.go | 5 +---- collector/pg_statio_user_tables.go | 5 +---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 7a03966aa..96487c898 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,7 @@ --- linters: enable: + - misspell - revive issues: @@ -14,3 +15,9 @@ linters-settings: exclude-functions: # Never check for logger errors. - (github.com/go-kit/log.Logger).Log + revive: + rules: + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter + - name: unused-parameter + severity: warning + disabled: true diff --git a/collector/pg_database.go b/collector/pg_database.go index 22d4918e4..d2c4b206a 100644 --- a/collector/pg_database.go +++ b/collector/pg_database.go @@ -115,10 +115,7 @@ func (c PGDatabaseCollector) Update(ctx context.Context, instance *instance, ch prometheus.GaugeValue, sizeMetric, datname, ) } - if err := rows.Err(); err != nil { - return err - } - return nil + return rows.Err() } func sliceContains(slice []string, s string) bool { diff --git a/collector/pg_replication_slot.go b/collector/pg_replication_slot.go index dec1b5da0..c625fd4d5 100644 --- a/collector/pg_replication_slot.go +++ b/collector/pg_replication_slot.go @@ -126,8 +126,5 @@ func (PGReplicationSlotCollector) Update(ctx context.Context, instance *instance prometheus.GaugeValue, isActiveValue, slotNameLabel, ) } - if err := rows.Err(); err != nil { - return err - } - return nil + return rows.Err() } diff --git a/collector/pg_statio_user_tables.go b/collector/pg_statio_user_tables.go index 89fdec532..4315fda0a 100644 --- a/collector/pg_statio_user_tables.go +++ b/collector/pg_statio_user_tables.go @@ -218,8 +218,5 @@ func (PGStatIOUserTablesCollector) Update(ctx context.Context, instance *instanc datnameLabel, schemanameLabel, relnameLabel, ) } - if err := rows.Err(); err != nil { - return err - } - return nil + return rows.Err() }