Skip to content

Commit 3d9ee5d

Browse files
authored
Merge pull request prometheus#2343 from binjip978/staticcheck-linux
Fix staticcheck warnings on linux
2 parents 6a5a238 + e5f384d commit 3d9ee5d

File tree

5 files changed

+4
-14
lines changed

5 files changed

+4
-14
lines changed

collector/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func bytesToString(byteArray []byte) string {
4848

4949
var metricNameRegex = regexp.MustCompile(`_*[^0-9A-Za-z_]+_*`)
5050

51-
// Sanitize the given metric name by replacing invalid characters by underscores.
51+
// SanitizeMetricName sanitize the given metric name by replacing invalid characters by underscores.
5252
//
5353
// OpenMetrics and the Prometheus exposition format require the metric name
5454
// to consist only of alphanumericals and "_", ":" and they must not start

collector/lnstat_linux.go

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

5050
netStats, err := fs.NetStat()
5151
if err != nil {
52-
return fmt.Errorf("Lnstat error: %s", err)
52+
return fmt.Errorf("lnstat error: %s", err)
5353
}
5454

5555
for _, netStatFile := range netStats {

collector/perf_linux.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func perfTracepointFlagToTracepoints(tracepointsFlag []string) ([]*perfTracepoin
5050
for i, tracepoint := range tracepointsFlag {
5151
split := strings.Split(tracepoint, ":")
5252
if len(split) != 2 {
53-
return nil, fmt.Errorf("Invalid tracepoint config %v", tracepoint)
53+
return nil, fmt.Errorf("invalid tracepoint config %v", tracepoint)
5454
}
5555
tracepoints[i] = &perfTracepoint{
5656
subsystem: split[0],
@@ -598,9 +598,6 @@ func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
598598
if err := (*profiler).Profile(hwProfile); err != nil {
599599
return err
600600
}
601-
if hwProfile == nil {
602-
continue
603-
}
604601

605602
cpuid := strconv.Itoa(c.hwProfilerCPUMap[profiler])
606603

@@ -670,9 +667,6 @@ func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
670667
if err := (*profiler).Profile(swProfile); err != nil {
671668
return err
672669
}
673-
if swProfile == nil {
674-
continue
675-
}
676670

677671
cpuid := strconv.Itoa(c.swProfilerCPUMap[profiler])
678672

@@ -726,9 +720,6 @@ func (c *perfCollector) updateCacheStats(ch chan<- prometheus.Metric) error {
726720
if err := (*profiler).Profile(cacheProfile); err != nil {
727721
return err
728722
}
729-
if cacheProfile == nil {
730-
continue
731-
}
732723

733724
cpuid := strconv.Itoa(c.cacheProfilerCPUMap[profiler])
734725

collector/systemd_linux.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ type systemdCollector struct {
7474
socketCurrentConnectionsDesc *prometheus.Desc
7575
socketRefusedConnectionsDesc *prometheus.Desc
7676
systemdVersionDesc *prometheus.Desc
77-
systemdVersion float64
7877
unitIncludePattern *regexp.Regexp
7978
unitExcludePattern *regexp.Regexp
8079
logger log.Logger

collector/systemd_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
package collector
1515

1616
import (
17-
"github.com/go-kit/log"
1817
"regexp"
1918
"testing"
2019

2120
"github.com/coreos/go-systemd/dbus"
21+
"github.com/go-kit/log"
2222
)
2323

2424
// Creates mock UnitLists

0 commit comments

Comments
 (0)