Skip to content

Commit 4ce508b

Browse files
committed
chore: Lint with golangci-lint v2
Signed-off-by: Manuel Rüger <[email protected]>
1 parent 38d32a3 commit 4ce508b

10 files changed

+19
-16
lines changed

collector/btrfs_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (c *btrfsCollector) Update(ch chan<- prometheus.Metric) error {
6969

7070
for _, s := range stats {
7171
// match up procfs and ioctl info by filesystem UUID (without dashes)
72-
var fsUUID = strings.Replace(s.UUID, "-", "", -1)
72+
var fsUUID = strings.ReplaceAll(s.UUID, "-", "")
7373
ioctlStats := ioctlStatsMap[fsUUID]
7474
c.updateBtrfsStats(ch, s, ioctlStats)
7575
}

collector/cpu_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func NewCPUCollector(logger *slog.Logger) (Collector, error) {
8787
isolcpus, err := sfs.IsolatedCPUs()
8888
if err != nil {
8989
if !os.IsNotExist(err) {
90-
return nil, fmt.Errorf("Unable to get isolated cpus: %w", err)
90+
return nil, fmt.Errorf("unable to get isolated cpus: %w", err)
9191
}
9292
logger.Debug("Could not open isolated file", "error", err)
9393
}

collector/cpu_netbsd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func getCPUTemperatures() (map[int]float64, error) {
155155
}
156156

157157
keys := sortFilterSysmonProperties(props, "coretemp")
158-
for idx, _ := range keys {
158+
for idx := range keys {
159159
convertTemperatures(props[keys[idx]], res)
160160
}
161161

collector/ethtool_linux_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,18 @@ func (e *EthtoolFixture) LinkInfo(intf string) (ethtool.EthtoolCmd, error) {
212212

213213
items := strings.Split(line, ": ")
214214
if items[0] == "Supported pause frame use" {
215-
if items[1] == "Symmetric" {
215+
switch items[1] {
216+
case "Symmetric":
216217
res.Supported |= (1 << unix.ETHTOOL_LINK_MODE_Pause_BIT)
217-
} else if items[1] == "Receive-only" {
218+
case "Receive-only":
218219
res.Supported |= (1 << unix.ETHTOOL_LINK_MODE_Asym_Pause_BIT)
219220
}
220221
}
221222
if items[0] == "Advertised pause frame use" {
222-
if items[1] == "Symmetric" {
223+
switch items[1] {
224+
case "Symmetric":
223225
res.Advertising |= (1 << unix.ETHTOOL_LINK_MODE_Pause_BIT)
224-
} else if items[1] == "Receive-only" {
226+
case "Receive-only":
225227
res.Advertising |= (1 << unix.ETHTOOL_LINK_MODE_Asym_Pause_BIT)
226228
}
227229
}

collector/filesystem_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ func parseFilesystemLabels(r io.Reader) ([]filesystemLabels, error) {
215215

216216
// Ensure we handle the translation of \040 and \011
217217
// as per fstab(5).
218-
parts[4] = strings.Replace(parts[4], "\\040", " ", -1)
219-
parts[4] = strings.Replace(parts[4], "\\011", "\t", -1)
218+
parts[4] = strings.ReplaceAll(parts[4], "\\040", " ")
219+
parts[4] = strings.ReplaceAll(parts[4], "\\011", "\t")
220220

221221
filesystems = append(filesystems, filesystemLabels{
222222
device: parts[m+3],

collector/meminfo_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func NewMeminfoCollector(logger *slog.Logger) (Collector, error) {
4444
func (c *meminfoCollector) getMemInfo() (map[string]float64, error) {
4545
meminfo, err := c.fs.Meminfo()
4646
if err != nil {
47-
return nil, fmt.Errorf("Failed to get memory info: %s", err)
47+
return nil, fmt.Errorf("failed to get memory info: %s", err)
4848
}
4949

5050
metrics := make(map[string]float64)

collector/perf_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func canTestPerf(t *testing.T) {
3333
if err != nil {
3434
t.Skip("Procfs not mounted, skipping perf tests")
3535
}
36-
paranoidStr := strings.Replace(string(paranoidBytes), "\n", "", -1)
36+
paranoidStr := strings.ReplaceAll(string(paranoidBytes), "\n", "")
3737
paranoid, err := strconv.Atoi(paranoidStr)
3838
if err != nil {
3939
t.Fatalf("Expected perf_event_paranoid to be an int, got: %s", paranoidStr)

collector/systemd_linux_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,12 @@ func TestSystemdSummary(t *testing.T) {
122122
summary := summarizeUnits(fixtures[0])
123123

124124
for _, state := range unitStatesName {
125-
if state == "inactive" {
125+
switch state {
126+
case "inactive":
126127
testSummaryHelper(t, state, summary[state], 3.0)
127-
} else if state == "active" {
128+
case "active":
128129
testSummaryHelper(t, state, summary[state], 1.0)
129-
} else {
130+
default:
130131
testSummaryHelper(t, state, summary[state], 0.0)
131132
}
132133
}

collector/zfs_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,5 +435,5 @@ type zfsSysctl string
435435

436436
func (s zfsSysctl) metricName() string {
437437
parts := strings.Split(string(s), ".")
438-
return strings.Replace(parts[len(parts)-1], "-", "_", -1)
438+
return strings.ReplaceAll(parts[len(parts)-1], "-", "_")
439439
}

node_exporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
112112
if err != nil {
113113
h.logger.Warn("Couldn't create filtered metrics handler:", "err", err)
114114
w.WriteHeader(http.StatusBadRequest)
115-
w.Write([]byte(fmt.Sprintf("Couldn't create filtered metrics handler: %s", err)))
115+
fmt.Fprintf(w, "Couldn't create filtered metrics handler: %s", err)
116116
return
117117
}
118118
filteredHandler.ServeHTTP(w, r)

0 commit comments

Comments
 (0)