Skip to content

Commit e7e52c2

Browse files
committed
Bump golangci-lint to v2.9.0
1 parent 50a8cc1 commit e7e52c2

9 files changed

Lines changed: 24 additions & 11 deletions

File tree

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ jobs:
1717
- name: golangci-lint
1818
uses: golangci/golangci-lint-action@v9
1919
with:
20-
version: v2.1.6
20+
version: v2.9.0

.golangci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ run:
33
tests: false
44
linters:
55
default: all
6+
enable:
7+
- wsl_v5
68
disable:
9+
- wsl
710
- cyclop
811
- depguard
912
- err113
@@ -25,6 +28,13 @@ linters:
2528
- varnamelen
2629
- wrapcheck
2730
- funlen
31+
settings:
32+
wsl_v5:
33+
allow-first-in-block: true
34+
allow-whole-block: true
35+
branch-max-lines: 2
36+
disable:
37+
- err
2838
exclusions:
2939
generated: lax
3040
presets:

cmd/alert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ inactive = 0`,
100100
if cliAlertConfig.AlertName != nil {
101101
check.ExitRaw(check.Unknown, "No such alert defined", "|", pdlist.String())
102102
}
103+
103104
check.ExitRaw(noAlertsState, "No alerts defined", "|", pdlist.String())
104105
}
105106

cmd/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func (c *Config) NewClient() *client.Client {
9090
// Using a Bearer Token for authentication
9191
if c.Bearer != "" {
9292
var t = config.NewInlineSecret(c.Bearer)
93+
9394
rt = config.NewAuthorizationCredentialsRoundTripper("Bearer", t, rt)
9495
}
9596

cmd/health.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Ready: Checks the readiness of an endpoint, which returns OK if the Prometheus s
2929

3030
// Creating an client and connecting to the API
3131
c := cliConfig.NewClient()
32+
3233
err := c.Connect()
3334
if err != nil {
3435
check.ExitError(err)
@@ -61,6 +62,7 @@ Ready: Checks the readiness of an endpoint, which returns OK if the Prometheus s
6162
if err != nil {
6263
check.ExitError(err)
6364
}
65+
6466
partialResult := result.NewPartialResult()
6567

6668
_ = partialResult.SetState(rc)

cmd/query.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
7979
}
8080

8181
c := cliConfig.NewClient()
82+
8283
err = c.Connect()
8384
if err != nil {
8485
check.ExitError(err)
@@ -93,6 +94,7 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
9394
if strings.Contains(err.Error(), "unmarshalerDecoder: unexpected value type \"string\"") {
9495
err = errors.New("string value results are not supported")
9596
}
97+
9698
check.ExitError(err)
9799
}
98100

@@ -112,10 +114,8 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
112114
case model.ValVector:
113115
// Instant vector - a set of time series containing a single sample for each time series, all sharing the same timestamp
114116
vectorVal := result.(model.Vector)
115-
116117
// Set initial capacity to reduce memory allocations
117118
for _, sample := range vectorVal {
118-
119119
numberValue := float64(sample.Value)
120120
partial := goresult.NewPartialResult()
121121

@@ -185,6 +185,7 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
185185
appendum := fmt.Sprintf("HTTP Warnings: %v", strings.Join(warnings, ", "))
186186
overall.Summary = overall.GetOutput() + appendum
187187
}
188+
188189
check.ExitRaw(overall.GetStatus(), overall.GetOutput())
189190
},
190191
}

cmd/root.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ func Execute(version string) {
2424
rootCmd.Version = version
2525
rootCmd.VersionTemplate()
2626

27-
if err := rootCmd.Execute(); err != nil {
27+
err := rootCmd.Execute()
28+
29+
if err != nil {
2830
check.ExitError(err)
2931
}
3032
}

internal/alert/alert.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616
alertnameLabelKey = "alertname"
1717
)
1818

19-
// Internal representation of Prometheus Rules.
19+
// Rule is the internal representation of a Prometheus Rules.
2020
// Alert attribute will be used when iterating over multiple AlertingRules.
2121
type Rule struct {
2222
AlertingRule v1.AlertingRule
@@ -139,7 +139,6 @@ func (a *Rule) GetOutput() (output string) {
139139
// Add current value to output
140140
value, _ = strconv.ParseFloat(a.Alert.Value, 32)
141141
out.WriteString(fmt.Sprintf(" is %s - value: %.2f", a.AlertingRule.State, value))
142-
143142
// Add labels to the output
144143
l, err := json.Marshal(a.Alert.Labels)
145144

internal/client/client.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package client
33
import (
44
"context"
55
"fmt"
6+
"maps"
67
"net/http"
78
"net/url"
89
"strings"
@@ -31,7 +32,6 @@ func (c *Client) Connect() error {
3132
Address: c.URL,
3233
RoundTripper: c.RoundTripper,
3334
})
34-
3535
if err != nil {
3636
return fmt.Errorf("error creating client: %w", err)
3737
}
@@ -113,10 +113,7 @@ func cloneRequest(r *http.Request) *http.Request {
113113
r2 := new(http.Request)
114114
*r2 = *r
115115
// Deep copy of the Header.
116-
r2.Header = make(http.Header)
117-
for k, s := range r.Header {
118-
r2.Header[k] = s
119-
}
116+
maps.Copy(r.Header, r2.Header)
120117

121118
return r2
122119
}

0 commit comments

Comments
 (0)