Skip to content

Multiple SA4031 linter errors #2596

@Berbe

Description

@Berbe

Host operating system

Debian x86_64 GNU/Linux

node_exporter version: output of node_exporter --version

Go 1.18.10 (also tested 1.9.5)
Building v1.5.0

What did you do that produced an error?

git clone --depth 1 --branch "v1.5.0" "https://github.com/prometheus/node_exporter.git" .
make

What did you expect to see?

Successful build

What did you see instead?

Error
6.424 /root/go/bin/golangci-lint run  ./...
20.30 collector/perf_linux.go:621:6: SA4031: this nil check is never true (staticcheck)
20.30                if hwProfile == nil {
20.30                   ^
20.30 collector/perf_linux.go:617:17: SA4031(related information): this is the value of hwProfile (staticcheck)
20.30                hwProfile := &perf.HardwareProfile{}
20.30                              ^
20.30 collector/perf_linux.go:709:6: SA4031: this nil check is never true (staticcheck)
20.30                if swProfile == nil {
20.30                   ^
20.30 collector/perf_linux.go:705:17: SA4031(related information): this is the value of swProfile (staticcheck)
20.30                swProfile := &perf.SoftwareProfile{}
20.30                              ^
20.30 collector/perf_linux.go:765:6: SA4031: this nil check is never true (staticcheck)
20.30                if cacheProfile == nil {
20.30                   ^
20.30 collector/perf_linux.go:761:20: SA4031(related information): this is the value of cacheProfile (staticcheck)
20.30                cacheProfile := &perf.CacheProfile{}
20.30                                 ^
20.32 make: *** [Makefile.common:171: common-lint] Error 1

Cf. SA4031 definition

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions