Skip to content

Commit 29d8a60

Browse files
committed
Fix some minor code style issues
- Unsused variables and unsused fmt methods
1 parent 5c129c5 commit 29d8a60

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

cmd/alert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ inactive = 0`,
3939
\_[OK] [PrometheusTargetMissing] is inactive
4040
\_[CRITICAL] [PrometheusAlertmanagerJobMissing] - Job: [alertmanager] is firing - value: 1.00
4141
| total=2 firing=1 pending=0 inactive=1`,
42-
Run: func(cmd *cobra.Command, args []string) {
42+
Run: func(_ *cobra.Command, _ []string) {
4343
var (
4444
counterFiring int
4545
counterPending int

cmd/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cmd
22

33
import (
44
"context"
5-
"fmt"
5+
"errors"
66
"net"
77
"net/http"
88
"net/url"
@@ -103,7 +103,7 @@ func (c *Config) NewClient() *client.Client {
103103
if c.BasicAuth != "" {
104104
s := strings.Split(c.BasicAuth, ":")
105105
if len(s) != 2 {
106-
check.ExitError(fmt.Errorf("specify the user name and password for server authentication <user:password>"))
106+
check.ExitError(errors.New("specify the user name and password for server authentication <user:password>"))
107107
}
108108

109109
var u = config.NewInlineSecret(s[0])

cmd/health.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package cmd
22

33
import (
4-
"fmt"
4+
"errors"
55

66
"github.com/NETWAYS/go-check"
77
"github.com/NETWAYS/go-check/result"
@@ -20,7 +20,7 @@ Ready: Checks the readiness of an endpoint, which returns OK if the Prometheus s
2020
2121
$ check_prometheus --bearer secrettoken health --ready
2222
OK - Prometheus Server is Ready. | statuscode=200`,
23-
Run: func(cmd *cobra.Command, args []string) {
23+
Run: func(_ *cobra.Command, _ []string) {
2424
var (
2525
rc int
2626
)
@@ -43,7 +43,7 @@ Ready: Checks the readiness of an endpoint, which returns OK if the Prometheus s
4343
rc, _, output, err := c.GetStatus(ctx, "ready")
4444

4545
if err != nil {
46-
check.ExitError(fmt.Errorf(output))
46+
check.ExitError(errors.New(output))
4747
}
4848

4949
partialResult := result.NewPartialResult()
@@ -81,7 +81,7 @@ Ready: Checks the readiness of an endpoint, which returns OK if the Prometheus s
8181
rc, _, output, err := c.GetStatus(ctx, "healthy")
8282

8383
if err != nil {
84-
check.ExitError(fmt.Errorf(output))
84+
check.ExitError(errors.New(output))
8585
}
8686

8787
partialResult := result.NewPartialResult()

cmd/query.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"errors"
45
"fmt"
56
"math"
67
"strconv"
@@ -61,12 +62,12 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
6162
\_[OK] go_gc_duration_seconds_count{instance="localhost:9090", job="prometheus"} - value: 1599
6263
\_[CRITICAL] go_gc_duration_seconds_count{instance="node-exporter:9100", job="node-exporter"} - value: 79610
6364
| value_go_gc_duration_seconds_count_localhost:9090_prometheus=1599 value_go_gc_duration_seconds_count_node-exporter:9100_node-exporter=79610`,
64-
PreRun: func(cmd *cobra.Command, args []string) {
65+
PreRun: func(_ *cobra.Command, _ []string) {
6566
if cliQueryConfig.Warning == "" || cliQueryConfig.Critical == "" {
66-
check.ExitError(fmt.Errorf("please specify warning and critical thresholds"))
67+
check.ExitError(errors.New("please specify warning and critical thresholds"))
6768
}
6869
},
69-
Run: func(cmd *cobra.Command, args []string) {
70+
Run: func(_ *cobra.Command, _ []string) {
7071
crit, err := check.ParseThreshold(cliQueryConfig.Critical)
7172
if err != nil {
7273
check.ExitError(err)
@@ -90,7 +91,7 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
9091

9192
if err != nil {
9293
if strings.Contains(err.Error(), "unmarshalerDecoder: unexpected value type \"string\"") {
93-
err = fmt.Errorf("string value results are not supported")
94+
err = errors.New("string value results are not supported")
9495
}
9596
check.ExitError(err)
9697
}
@@ -99,15 +100,15 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
99100

100101
switch result.Type() {
101102
default:
102-
check.ExitError(fmt.Errorf("none value results are not supported"))
103+
check.ExitError(errors.New("none value results are not supported"))
103104
// Scalar - a simple numeric floating point value
104105
case model.ValScalar:
105-
check.ExitError(fmt.Errorf("scalar value results are not supported"))
106+
check.ExitError(errors.New("scalar value results are not supported"))
106107
case model.ValNone:
107-
check.ExitError(fmt.Errorf("none value results are not supported"))
108+
check.ExitError(errors.New("none value results are not supported"))
108109
case model.ValString:
109110
// String - a simple string value; currently unused
110-
check.ExitError(fmt.Errorf("string value results are not supported"))
111+
check.ExitError(errors.New("string value results are not supported"))
111112
case model.ValVector:
112113
// Instant vector - a set of time series containing a single sample for each time series, all sharing the same timestamp
113114
vectorVal := result.(model.Vector)

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var Timeout = 30
1212
var rootCmd = &cobra.Command{
1313
Use: "check_prometheus",
1414
Short: "An Icinga check plugin to check Prometheus",
15-
PersistentPreRun: func(cmd *cobra.Command, args []string) {
15+
PersistentPreRun: func(_ *cobra.Command, _ []string) {
1616
go check.HandleTimeout(Timeout)
1717
},
1818
Run: Usage,

0 commit comments

Comments
 (0)