Merge pull request #807 from prometheus-community/superq/linting

Update linting
This commit is contained in:
Joe Adams 2023-06-03 20:48:27 -04:00 committed by GitHub
commit 5d5fae151b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 18 deletions

View File

@ -1,4 +1,8 @@
---
linters:
enable:
- revive
issues:
exclude-rules:
- path: _test.go
@ -7,4 +11,6 @@ issues:
linters-settings:
errcheck:
exclude: scripts/errcheck_excludes.txt
exclude-functions:
# Never check for logger errors.
- (github.com/go-kit/log.Logger).Log

View File

@ -34,7 +34,7 @@ import (
)
var (
c = config.ConfigHandler{
c = config.Handler{
Config: &config.Config{},
}

View File

@ -66,27 +66,27 @@ func (PGReplicationSlotCollector) Update(ctx context.Context, db *sql.DB, ch cha
defer rows.Close()
for rows.Next() {
var slot_name string
var wal_lsn int64
var flush_lsn int64
var is_active bool
if err := rows.Scan(&slot_name, &wal_lsn, &flush_lsn, &is_active); err != nil {
var slotName string
var walLSN int64
var flusLSN int64
var isActive bool
if err := rows.Scan(&slotName, &walLSN, &flusLSN, &isActive); err != nil {
return err
}
ch <- prometheus.MustNewConstMetric(
pgReplicationSlotCurrentWalDesc,
prometheus.GaugeValue, float64(wal_lsn), slot_name,
prometheus.GaugeValue, float64(walLSN), slotName,
)
if is_active {
if isActive {
ch <- prometheus.MustNewConstMetric(
pgReplicationSlotCurrentFlushDesc,
prometheus.GaugeValue, float64(flush_lsn), slot_name,
prometheus.GaugeValue, float64(flusLSN), slotName,
)
}
ch <- prometheus.MustNewConstMetric(
pgReplicationSlotIsActiveDesc,
prometheus.GaugeValue, float64(flush_lsn), slot_name,
prometheus.GaugeValue, float64(flusLSN), slotName,
)
}
if err := rows.Err(); err != nil {

View File

@ -54,18 +54,18 @@ type UserPass struct {
Password string `yaml:"password"`
}
type ConfigHandler struct {
type Handler struct {
sync.RWMutex
Config *Config
}
func (ch *ConfigHandler) GetConfig() *Config {
func (ch *Handler) GetConfig() *Config {
ch.RLock()
defer ch.RUnlock()
return ch.Config
}
func (ch *ConfigHandler) ReloadConfig(f string, logger log.Logger) error {
func (ch *Handler) ReloadConfig(f string, logger log.Logger) error {
config := &Config{}
var err error
defer func() {

View File

@ -18,7 +18,7 @@ import (
)
func TestLoadConfig(t *testing.T) {
ch := &ConfigHandler{
ch := &Handler{
Config: &Config{},
}
@ -29,7 +29,7 @@ func TestLoadConfig(t *testing.T) {
}
func TestLoadBadConfigs(t *testing.T) {
ch := &ConfigHandler{
ch := &Handler{
Config: &Config{},
}

View File

@ -1,2 +0,0 @@
// Never check for logger errors.
(github.com/go-kit/log.Logger).Log