Skip to content

Commit 0123c35

Browse files
committed
FIX lint issues
1 parent 9486c39 commit 0123c35

23 files changed

+50
-104
lines changed

collector/cluster_health.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package collector
1616
import (
1717
"encoding/json"
1818
"fmt"
19-
"io/ioutil"
19+
"io"
2020
"net/http"
2121
"net/url"
2222
"path"
@@ -256,7 +256,7 @@ func (c *ClusterHealth) fetchAndDecodeClusterHealth() (clusterHealthResponse, er
256256
return chr, fmt.Errorf("HTTP Request failed with code %d", res.StatusCode)
257257
}
258258

259-
bts, err := ioutil.ReadAll(res.Body)
259+
bts, err := io.ReadAll(res.Body)
260260
if err != nil {
261261
c.jsonParseFailures.Inc()
262262
return chr, err

collector/cluster_health_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestClusterHealth(t *testing.T) {
3434
"5.4.2": `{"cluster_name":"elasticsearch","status":"yellow","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"active_primary_shards":5,"active_shards":5,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":5,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":12,"active_shards_percent_as_number":50.0}`,
3535
}
3636
for ver, out := range tcs {
37-
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
37+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
3838
fmt.Fprintln(w, out)
3939
}))
4040
defer ts.Close()

collector/cluster_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package collector
1616
import (
1717
"context"
1818
"encoding/json"
19-
"io/ioutil"
19+
"io"
2020
"net/http"
2121
"net/url"
2222

@@ -77,13 +77,13 @@ type VersionInfo struct {
7777
LuceneVersion semver.Version `json:"lucene_version"`
7878
}
7979

80-
func (c *ClusterInfoCollector) Update(ctx context.Context, ch chan<- prometheus.Metric) error {
80+
func (c *ClusterInfoCollector) Update(_ context.Context, ch chan<- prometheus.Metric) error {
8181
resp, err := c.hc.Get(c.u.String())
8282
if err != nil {
8383
return err
8484
}
8585
defer resp.Body.Close()
86-
b, err := ioutil.ReadAll(resp.Body)
86+
b, err := io.ReadAll(resp.Body)
8787
if err != nil {
8888
return err
8989
}

collector/cluster_settings.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package collector
1616
import (
1717
"encoding/json"
1818
"fmt"
19-
"io/ioutil"
19+
"io"
2020
"net/http"
2121
"net/url"
2222
"path"
@@ -100,7 +100,7 @@ func (cs *ClusterSettings) getAndParseURL(u *url.URL, data interface{}) error {
100100
return fmt.Errorf("HTTP Request failed with code %d", res.StatusCode)
101101
}
102102

103-
bts, err := ioutil.ReadAll(res.Body)
103+
bts, err := io.ReadAll(res.Body)
104104
if err != nil {
105105
cs.jsonParseFailures.Inc()
106106
return err

collector/cluster_settings_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestClusterSettingsStats(t *testing.T) {
3333
f, _ := os.Open(filename)
3434
defer f.Close()
3535
for hn, handler := range map[string]http.Handler{
36-
"plain": http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
36+
"plain": http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
3737
io.Copy(w, f)
3838
}),
3939
} {
@@ -69,7 +69,7 @@ func TestClusterMaxShardsPerNode(t *testing.T) {
6969
f, _ := os.Open(filename)
7070
defer f.Close()
7171
for hn, handler := range map[string]http.Handler{
72-
"plain": http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
72+
"plain": http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
7373
io.Copy(w, f)
7474
}),
7575
} {

collector/collector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ func execute(ctx context.Context, name string, c Collector, ch chan<- prometheus
202202
// A new action function is needed for each collector flag because the ParseContext
203203
// does not contain information about which flag called the action.
204204
// See: https://github.com/alecthomas/kingpin/issues/294
205-
func collectorFlagAction(collector string) func(ctx *kingpin.ParseContext) error {
206-
return func(ctx *kingpin.ParseContext) error {
205+
func collectorFlagAction(collector string) func(_ *kingpin.ParseContext) error {
206+
return func(_ *kingpin.ParseContext) error {
207207
forcedCollectors[collector] = true
208208
return nil
209209
}

collector/indices.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ package collector
1616
import (
1717
"encoding/json"
1818
"fmt"
19-
"github.com/go-kit/log"
20-
"github.com/go-kit/log/level"
21-
"github.com/prometheus-community/elasticsearch_exporter/pkg/clusterinfo"
22-
"github.com/prometheus/client_golang/prometheus"
23-
"io/ioutil"
19+
"io"
2420
"net/http"
2521
"net/url"
2622
"path"
2723
"sort"
2824
"strconv"
25+
26+
"github.com/go-kit/log"
27+
"github.com/go-kit/log/level"
28+
"github.com/prometheus-community/elasticsearch_exporter/pkg/clusterinfo"
29+
"github.com/prometheus/client_golang/prometheus"
2930
)
3031

3132
type labels struct {
@@ -1183,7 +1184,7 @@ func (i *Indices) queryURL(u *url.URL) ([]byte, error) {
11831184
return []byte{}, fmt.Errorf("HTTP Request failed with code %d", res.StatusCode)
11841185
}
11851186

1186-
bts, err := ioutil.ReadAll(res.Body)
1187+
bts, err := io.ReadAll(res.Body)
11871188
if err != nil {
11881189
return []byte{}, err
11891190
}

collector/indices_mappings.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package collector
1616
import (
1717
"encoding/json"
1818
"fmt"
19-
"io/ioutil"
19+
"io"
2020
"net/http"
2121
"net/url"
2222
"path"
@@ -132,7 +132,7 @@ func (im *IndicesMappings) getAndParseURL(u *url.URL) (*IndicesMappingsResponse,
132132
return nil, fmt.Errorf("HTTP Request failed with code %d", res.StatusCode)
133133
}
134134

135-
body, err := ioutil.ReadAll(res.Body)
135+
body, err := io.ReadAll(res.Body)
136136
if err != nil {
137137
_ = level.Warn(im.logger).Log("msg", "failed to read response body", "err", err)
138138
return nil, err

collector/indices_mappings_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func TestMapping(t *testing.T) {
113113
}
114114
for ver, out := range tcs {
115115
for hn, handler := range map[string]http.Handler{
116-
"plain": http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
116+
"plain": http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
117117
fmt.Fprintln(w, out)
118118
}),
119119
} {

collector/indices_settings.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package collector
1616
import (
1717
"encoding/json"
1818
"fmt"
19-
"io/ioutil"
19+
"io"
2020
"net/http"
2121
"net/url"
2222
"path"
@@ -123,7 +123,7 @@ func (cs *IndicesSettings) getAndParseURL(u *url.URL, data interface{}) error {
123123
return fmt.Errorf("HTTP Request failed with code %d", res.StatusCode)
124124
}
125125

126-
bts, err := ioutil.ReadAll(res.Body)
126+
bts, err := io.ReadAll(res.Body)
127127
if err != nil {
128128
cs.jsonParseFailures.Inc()
129129
return err

0 commit comments

Comments
 (0)