Skip to content

fix the static ckeck linter issues#1114

Merged
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
SergeyKanzhelev:staticchecklinter
Sep 9, 2025
Merged

fix the static ckeck linter issues#1114
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
SergeyKanzhelev:staticchecklinter

Conversation

@SergeyKanzhelev

Copy link
Copy Markdown
Member

Tried fixing most of them with AI. Ended up cleaning up after it a lot. Anyways, a few improvements here:

./.bin/golangci-lint run --config .golangci.yml ./...
pkg/custompluginmonitor/types/config.go:164:11: ST1005: error strings should not end with punctuation or newlines (staticcheck)
                        return fmt.Errorf("Permanent problem %s does not have preset default condition.", conditionType)
                               ^
pkg/exporters/k8sexporter/condition/manager.go:123:4: SA4011: ineffective break statement. Did you mean to break out of the outer loop? (staticcheck)
                        break
                        ^
pkg/exporters/k8sexporter/condition/manager_test.go:86:27: QF1009: probably want to use time.Time.Equal instead (staticcheck)
                        for now := time.Now(); now == time.Now(); {
                                               ^
pkg/exporters/k8sexporter/problemclient/configs.go:92:15: QF1008: could remove embedded field "TLSClientConfig" from selector (staticcheck)
                        kubeConfig.TLSClientConfig.CAFile = ""
                                   ^
pkg/exporters/prometheusexporter/prometheus_exporter.go:59:2: S1023: redundant return statement (staticcheck)
        return
        ^
pkg/exporters/stackdriver/gce/type.go:42:23: SA1019: metadata.ProjectID is deprecated: Please use the context aware variant [ProjectIDWithContext]. (staticcheck)
                md.ProjectID, err = metadata.ProjectID()
                                    ^
pkg/exporters/stackdriver/gce/type.go:48:18: SA1019: metadata.Zone is deprecated: Please use the context aware variant [ZoneWithContext]. (staticcheck)
                md.Zone, err = metadata.Zone()
                               ^
pkg/exporters/stackdriver/gce/type.go:54:24: SA1019: metadata.InstanceID is deprecated: Please use the context aware variant [InstanceIDWithContext]. (staticcheck)
                md.InstanceID, err = metadata.InstanceID()
                                     ^
pkg/exporters/stackdriver/gce/type.go:60:26: SA1019: metadata.InstanceName is deprecated: Please use the context aware variant [InstanceNameWithContext]. (staticcheck)
                md.InstanceName, err = metadata.InstanceName()
                                       ^
pkg/exporters/stackdriver/stackdriver_exporter.go:189:2: S1023: redundant return statement (staticcheck)
        return
        ^
pkg/problemmetrics/problem_metrics.go:81:10: ST1005: error strings should not end with punctuation or newlines (staticcheck)
                return errors.New("problem counter is being incremented before initialized.")
                       ^
pkg/problemmetrics/problem_metrics.go:90:10: ST1005: error strings should not end with punctuation or newlines (staticcheck)
                return errors.New("problem gauge is being set before initialized.")
                       ^
pkg/systemlogmonitor/config.go:57:8: QF1008: could remove embedded field "WatcherConfig" from selector (staticcheck)
        if mc.WatcherConfig.Lookback == "" {
              ^
pkg/systemlogmonitor/config.go:58:6: QF1008: could remove embedded field "WatcherConfig" from selector (staticcheck)
                mc.WatcherConfig.Lookback = defaultLookback
                   ^
pkg/systemlogmonitor/log_buffer.go:50:30: S1019: should use make([]*types.Log, maxLines) instead (staticcheck)
                buffer: make([]*types.Log, maxLines, maxLines),
                                           ^
pkg/systemlogmonitor/log_buffer.go:51:26: S1019: should use make([]string, maxLines) instead (staticcheck)
                msg:    make([]string, maxLines, maxLines),
                                       ^
pkg/systemlogmonitor/log_monitor_test.go:28:2: ST1019: package "k8s.io/node-problem-detector/pkg/systemlogmonitor/types" is being imported more than once (staticcheck)
        logtypes "k8s.io/node-problem-detector/pkg/systemlogmonitor/types"
        ^
pkg/systemlogmonitor/log_monitor_test.go:29:2: ST1019(related information): other import of "k8s.io/node-problem-detector/pkg/systemlogmonitor/types" (staticcheck)
        systemlogtypes "k8s.io/node-problem-detector/pkg/systemlogmonitor/types"
        ^
pkg/util/helpers_linux.go:76:14: ST1005: error strings should not be capitalized (staticcheck)
                return "", fmt.Errorf("Unsupported ID in /etc/os-release: %q", osReleaseMap["ID"])
                           ^
pkg/util/metrics/helpers.go:90:4: QF1003: could use tagged switch on *metricFamily.Type (staticcheck)
                        if *metricFamily.Type == pcm.MetricType_COUNTER {
                        ^
20 issues:
* staticcheck: 20
make: *** [Makefile:120: lint] Error 1

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 8, 2025
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 8, 2025
@SergeyKanzhelev

Copy link
Copy Markdown
Member Author

/retest

@hakman

hakman commented Sep 9, 2025

Copy link
Copy Markdown
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 9, 2025
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hakman, SergeyKanzhelev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 2fc1699 into kubernetes:master Sep 9, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants