Skip to content

Commit

Permalink
ci: more better golang lint check (#62)
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z authored Oct 17, 2023
1 parent 5591ccb commit 1888df8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 64 deletions.
24 changes: 12 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
linters:
enable:
- misspell
- revive
disable:
- deadcode
- unused
- structcheck
- varcheck

issues:
exclude-rules:
- path: _test.go
linters:
- errcheck

linters-settings:
errcheck:
exclude: scripts/errcheck_excludes.txt
exclude-functions:
# Used in HTTP handlers, any error is handled by the server itself.
- (net/http.ResponseWriter).Write
# 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
46 changes: 0 additions & 46 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,49 +121,3 @@ var ErrNoData = errors.New("collector returned no data")
func IsNoDataError(err error) bool {
return err == ErrNoData
}

// pushMetric helps construct and convert a variety of value types into Prometheus float64 metrics.
func pushMetric(ch chan<- prometheus.Metric, fieldDesc *prometheus.Desc, name string, value interface{}, valueType prometheus.ValueType, labelValues ...string) {
var fVal float64
switch val := value.(type) {
case uint8:
fVal = float64(val)
case uint16:
fVal = float64(val)
case uint32:
fVal = float64(val)
case uint64:
fVal = float64(val)
case int64:
fVal = float64(val)
case *uint8:
if val == nil {
return
}
fVal = float64(*val)
case *uint16:
if val == nil {
return
}
fVal = float64(*val)
case *uint32:
if val == nil {
return
}
fVal = float64(*val)
case *uint64:
if val == nil {
return
}
fVal = float64(*val)
case *int64:
if val == nil {
return
}
fVal = float64(*val)
default:
return
}

ch <- prometheus.MustNewConstMetric(fieldDesc, valueType, fVal, labelValues...)
}
2 changes: 1 addition & 1 deletion config/example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ probes:
username:
password:
topic:
qos:
qos:
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func runCommandAndTests(cmd *exec.Cmd, address string, fn func(pid int) error) e

err := <-errc
if cmd.Process != nil {
cmd.Process.Kill()
_ = cmd.Process.Kill()
}
return err
}
4 changes: 0 additions & 4 deletions scripts/errcheck_excludes.txt

This file was deleted.

0 comments on commit 1888df8

Please sign in to comment.