Skip to content

Commit 9ffd382

Browse files
committed
Fix some minor code style issues
1 parent 07f1364 commit 9ffd382

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

cmd/config.go

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

33
import (
4-
"fmt"
4+
"errors"
55
"net"
66
"net/http"
77
"net/url"
@@ -94,7 +94,7 @@ func (c *Config) NewClient() *client.Client {
9494
if c.BasicAuth != "" {
9595
s := strings.Split(c.BasicAuth, ":")
9696
if len(s) != 2 {
97-
check.ExitError(fmt.Errorf("specify the user name and password for server authentication <user:password>"))
97+
check.ExitError(errors.New("specify the user name and password for server authentication <user:password>"))
9898
}
9999

100100
var u = s[0]

cmd/health.go

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

33
import (
44
"encoding/json"
5+
"errors"
56
"fmt"
67
"net/http"
78
"net/url"
@@ -139,7 +140,7 @@ var healthCmd = &cobra.Command{
139140
\_[OK] Heap usage at 12.00%
140141
\_[OK] Open file descriptors at 12.00%
141142
\_[WARNING] CPU usage at 55.00%`,
142-
Run: func(cmd *cobra.Command, args []string) {
143+
Run: func(_ *cobra.Command, _ []string) {
143144
var (
144145
output string
145146
rc int
@@ -192,7 +193,7 @@ var healthCmd = &cobra.Command{
192193
// Logstash Health Status
193194
switch stat.Status {
194195
default:
195-
check.ExitError(fmt.Errorf("could not determine status"))
196+
check.ExitError(errors.New("could not determine status"))
196197
case "green":
197198
states = append(states, check.OK)
198199
case "yellow":

cmd/pipeline.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ var pipelineCmd = &cobra.Command{
7676
$ check_logstash pipeline --inflight-events-warn 5 --inflight-events-crit 10 --pipeline example
7777
CRITICAL - Inflight events
7878
\_[CRITICAL] inflight_events_example:15`,
79-
Run: func(cmd *cobra.Command, args []string) {
79+
Run: func(_ *cobra.Command, _ []string) {
8080
var (
8181
output string
8282
rc int
@@ -143,7 +143,7 @@ var pipelineCmd = &cobra.Command{
143143
Uom: "c",
144144
Value: pipe.Events.Out})
145145
perfList.Add(&perfdata.Perfdata{
146-
Label: fmt.Sprintf("inflight_events_%s", name),
146+
Label: fmt.Sprintf("inflight_events_%s", name), //nolint: perfsprint
147147
Warn: thresholds.Warning,
148148
Crit: thresholds.Critical,
149149
Value: inflightEvents})
@@ -187,7 +187,7 @@ var pipelineReloadCmd = &cobra.Command{
187187
$ check_logstash pipeline reload --pipeline Example
188188
CRITICAL - Configuration reload failed
189189
\_[CRITICAL] Configuration reload for pipeline Example failed on 2021-01-01T02:07:14Z`,
190-
Run: func(cmd *cobra.Command, args []string) {
190+
Run: func(_ *cobra.Command, _ []string) {
191191
var (
192192
output string
193193
rc int
@@ -278,7 +278,7 @@ var pipelineFlowCmd = &cobra.Command{
278278
$ check_logstash pipeline flow --pipeline example --warning 5 --critical 10
279279
CRITICAL - Flow metrics not alright
280280
\_[CRITICAL] queue_backpressure_example:11.23;`,
281-
Run: func(cmd *cobra.Command, args []string) {
281+
Run: func(_ *cobra.Command, _ []string) {
282282
var (
283283
output string
284284
rc int
@@ -335,7 +335,7 @@ var pipelineFlowCmd = &cobra.Command{
335335

336336
// Generate perfdata for each event
337337
perfList.Add(&perfdata.Perfdata{
338-
Label: fmt.Sprintf("pipelines.queue_backpressure_%s", name),
338+
Label: fmt.Sprintf("pipelines.queue_backpressure_%s", name), //nolint: perfsprint
339339
Warn: thresholds.Warning,
340340
Crit: thresholds.Critical,
341341
Value: pipe.Flow.QueueBackpressure.Current})

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_logstash",
1414
Short: "An Icinga check plugin to check Logstash",
15-
PersistentPreRun: func(cmd *cobra.Command, args []string) {
15+
PersistentPreRun: func(_ *cobra.Command, _ []string) {
1616
go check.HandleTimeout(Timeout)
1717
},
1818
Run: Usage,

internal/logstash/api.go

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

33
import (
44
"encoding/json"
5-
"fmt"
5+
"errors"
66
"strconv"
77
"strings"
88
)
@@ -95,7 +95,7 @@ func (s *Stat) UnmarshalJSON(b []byte) error {
9595
majorVersion, convErr := strconv.Atoi(v[0])
9696

9797
if convErr != nil {
98-
return fmt.Errorf("could not determine version")
98+
return errors.New("could not determine version")
9999
}
100100

101101
s.MajorVersion = majorVersion

0 commit comments

Comments
 (0)