Skip to content

Commit 5d5fae1

Browse files
authored
Merge pull request prometheus-community#807 from prometheus-community/superq/linting
Update linting
2 parents 214d76f + fab8e62 commit 5d5fae1

File tree

6 files changed

+22
-18
lines changed

6 files changed

+22
-18
lines changed

.golangci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
---
2+
linters:
3+
enable:
4+
- revive
5+
26
issues:
37
exclude-rules:
48
- path: _test.go
@@ -7,4 +11,6 @@ issues:
711

812
linters-settings:
913
errcheck:
10-
exclude: scripts/errcheck_excludes.txt
14+
exclude-functions:
15+
# Never check for logger errors.
16+
- (github.com/go-kit/log.Logger).Log

cmd/postgres_exporter/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
)
3535

3636
var (
37-
c = config.ConfigHandler{
37+
c = config.Handler{
3838
Config: &config.Config{},
3939
}
4040

collector/replication_slots.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,27 +66,27 @@ func (PGReplicationSlotCollector) Update(ctx context.Context, db *sql.DB, ch cha
6666
defer rows.Close()
6767

6868
for rows.Next() {
69-
var slot_name string
70-
var wal_lsn int64
71-
var flush_lsn int64
72-
var is_active bool
73-
if err := rows.Scan(&slot_name, &wal_lsn, &flush_lsn, &is_active); err != nil {
69+
var slotName string
70+
var walLSN int64
71+
var flusLSN int64
72+
var isActive bool
73+
if err := rows.Scan(&slotName, &walLSN, &flusLSN, &isActive); err != nil {
7474
return err
7575
}
7676

7777
ch <- prometheus.MustNewConstMetric(
7878
pgReplicationSlotCurrentWalDesc,
79-
prometheus.GaugeValue, float64(wal_lsn), slot_name,
79+
prometheus.GaugeValue, float64(walLSN), slotName,
8080
)
81-
if is_active {
81+
if isActive {
8282
ch <- prometheus.MustNewConstMetric(
8383
pgReplicationSlotCurrentFlushDesc,
84-
prometheus.GaugeValue, float64(flush_lsn), slot_name,
84+
prometheus.GaugeValue, float64(flusLSN), slotName,
8585
)
8686
}
8787
ch <- prometheus.MustNewConstMetric(
8888
pgReplicationSlotIsActiveDesc,
89-
prometheus.GaugeValue, float64(flush_lsn), slot_name,
89+
prometheus.GaugeValue, float64(flusLSN), slotName,
9090
)
9191
}
9292
if err := rows.Err(); err != nil {

config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ type UserPass struct {
5454
Password string `yaml:"password"`
5555
}
5656

57-
type ConfigHandler struct {
57+
type Handler struct {
5858
sync.RWMutex
5959
Config *Config
6060
}
6161

62-
func (ch *ConfigHandler) GetConfig() *Config {
62+
func (ch *Handler) GetConfig() *Config {
6363
ch.RLock()
6464
defer ch.RUnlock()
6565
return ch.Config
6666
}
6767

68-
func (ch *ConfigHandler) ReloadConfig(f string, logger log.Logger) error {
68+
func (ch *Handler) ReloadConfig(f string, logger log.Logger) error {
6969
config := &Config{}
7070
var err error
7171
defer func() {

config/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
func TestLoadConfig(t *testing.T) {
21-
ch := &ConfigHandler{
21+
ch := &Handler{
2222
Config: &Config{},
2323
}
2424

@@ -29,7 +29,7 @@ func TestLoadConfig(t *testing.T) {
2929
}
3030

3131
func TestLoadBadConfigs(t *testing.T) {
32-
ch := &ConfigHandler{
32+
ch := &Handler{
3333
Config: &Config{},
3434
}
3535

scripts/errcheck_excludes.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)