enabled a few more linter rules

This commit is contained in:
Sergey Kanzhelev
2025-09-11 18:47:20 +00:00
parent 0fe2979ff1
commit 3e64800668
8 changed files with 139 additions and 9 deletions
+1
View File
@@ -21,6 +21,7 @@ import (
)
func TestGetOSVersionLinux(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
fakeOSReleasePath string
+1 -1
View File
@@ -56,7 +56,7 @@ func TestPrometheusMetricsParsingAndMatching(t *testing.T) {
// Metric with non-existent label.
{
Name: "host_uptime",
Labels: map[string]string{"non-existant-version": "0.0.1"},
Labels: map[string]string{"non-existent-version": "0.0.1"},
},
// Metric with incorrect label.
{
+7 -1
View File
@@ -17,6 +17,8 @@ import (
"encoding/json"
"fmt"
"strings"
"k8s.io/klog/v2"
)
type CmdlineArg struct {
@@ -25,7 +27,11 @@ type CmdlineArg struct {
}
func (d CmdlineArg) String() string {
s, _ := json.Marshal(d)
s, err := json.Marshal(d)
if err != nil {
klog.Errorf("failed to marshal cmdline arg: %v", err)
return ""
}
return string(s)
}
+7 -1
View File
@@ -18,6 +18,8 @@ import (
"fmt"
"strconv"
"strings"
"k8s.io/klog/v2"
)
type Module struct {
@@ -29,7 +31,11 @@ type Module struct {
}
func (d Module) String() string {
s, _ := json.Marshal(d)
s, err := json.Marshal(d)
if err != nil {
klog.Errorf("failed to marshal module stat: %v", err)
return ""
}
return string(s)
}