Skip to content

Commit 5f917cc

Browse files
authored
Improve linting (prometheus-community#861)
* Disable unused-parameter check due to false positives on Collect() calls. * Enable misspell. * Simplify error returns. Signed-off-by: SuperQ <[email protected]>
1 parent 6b56e2f commit 5f917cc

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

.golangci.yml

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
linters:
33
enable:
4+
- misspell
45
- revive
56

67
issues:
@@ -14,3 +15,9 @@ linters-settings:
1415
exclude-functions:
1516
# Never check for logger errors.
1617
- (github.com/go-kit/log.Logger).Log
18+
revive:
19+
rules:
20+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
21+
- name: unused-parameter
22+
severity: warning
23+
disabled: true

collector/pg_database.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,7 @@ func (c PGDatabaseCollector) Update(ctx context.Context, instance *instance, ch
115115
prometheus.GaugeValue, sizeMetric, datname,
116116
)
117117
}
118-
if err := rows.Err(); err != nil {
119-
return err
120-
}
121-
return nil
118+
return rows.Err()
122119
}
123120

124121
func sliceContains(slice []string, s string) bool {

collector/pg_replication_slot.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,5 @@ func (PGReplicationSlotCollector) Update(ctx context.Context, instance *instance
126126
prometheus.GaugeValue, isActiveValue, slotNameLabel,
127127
)
128128
}
129-
if err := rows.Err(); err != nil {
130-
return err
131-
}
132-
return nil
129+
return rows.Err()
133130
}

collector/pg_statio_user_tables.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,5 @@ func (PGStatIOUserTablesCollector) Update(ctx context.Context, instance *instanc
218218
datnameLabel, schemanameLabel, relnameLabel,
219219
)
220220
}
221-
if err := rows.Err(); err != nil {
222-
return err
223-
}
224-
return nil
221+
return rows.Err()
225222
}

0 commit comments

Comments
 (0)