Skip to content

NO-JIRA: Fix staticcheck warnings in pkg/cli/admin/mustgather#2306

Open
ankimaha-sys wants to merge 1 commit into
openshift:mainfrom
ankimaha-sys:fix-mustgather-staticcheck-warnings
Open

NO-JIRA: Fix staticcheck warnings in pkg/cli/admin/mustgather#2306
ankimaha-sys wants to merge 1 commit into
openshift:mainfrom
ankimaha-sys:fix-mustgather-staticcheck-warnings

Conversation

@ankimaha-sys

@ankimaha-sys ankimaha-sys commented Jul 8, 2026

Copy link
Copy Markdown

Description

Address several staticcheck findings in the must-gather package:

  • Remove unnecessary fmt.Sprintf calls wrapping plain strings (S1039)
  • Eliminate unused make() allocation overwritten on next line (SA4006)
  • Use time.Since instead of time.Now().Sub (S1012)
  • Remove redundant return at end of function (S1023)

Changes

  • mustgather.go: Remove two instances of fmt.Sprintf with no format verbs, consolidate variable declaration to avoid wasted allocation, remove trailing return
  • summary.go: Replace time.Now().Sub(x) with idiomatic time.Since(x), remove fmt.Sprintf with no format verbs

All changes are mechanical and do not alter runtime behavior.

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes

    • Improved the consistency of must-gather fallback output and cluster version status summaries.
    • Simplified option conflict handling and image resolution logic for more reliable behavior.
  • Chores

    • Cleaned up internal string handling and removed a few unnecessary formatting steps.

Address several staticcheck findings in the must-gather package:
- Remove unnecessary fmt.Sprintf calls wrapping plain strings (S1039)
- Eliminate unused make() allocation overwritten on next line (SA4006)
- Use time.Since instead of time.Now().Sub (S1012)
- Remove redundant return at end of function (S1023)
Signed-off-by: Ankit Mahajan  ankimaha@redhat.com

Signed-off-by: Ankit Mahajan <ankimaha@redhat.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 8, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@ankimaha-sys: This pull request explicitly references no jira issue.

Details

In response to this:

Description

Address several staticcheck findings in the must-gather package:

  • Remove unnecessary fmt.Sprintf calls wrapping plain strings (S1039)
  • Eliminate unused make() allocation overwritten on next line (SA4006)
  • Use time.Since instead of time.Now().Sub (S1012)
  • Remove redundant return at end of function (S1023)

Changes

  • mustgather.go: Remove two instances of fmt.Sprintf with no format verbs, consolidate variable declaration to avoid wasted allocation, remove trailing return
  • summary.go: Replace time.Now().Sub(x) with idiomatic time.Since(x), remove fmt.Sprintf with no format verbs

All changes are mechanical and do not alter runtime behavior.

Made with Cursor

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot requested review from ingvagabund and tchap July 8, 2026 19:54
@openshift-ci openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 8, 2026
@openshift-ci

openshift-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Hi @ankimaha-sys. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: d4aad3b1-23f6-4e01-8852-edbcb4ba0f80

📥 Commits

Reviewing files that changed from the base of the PR and between 22c69c0 and 10c6a5a.

📒 Files selected for processing (2)
  • pkg/cli/admin/mustgather/mustgather.go
  • pkg/cli/admin/mustgather/summary.go

Walkthrough

Minor refactors in must-gather CLI code replace fmt.Sprintf calls with direct string literals/constants, simplify a plugin image map assignment, remove a redundant explicit return, and switch a duration calculation from time.Now().Sub to time.Since.

Changes

Must-gather cleanups

Layer / File(s) Summary
String and assignment simplifications
pkg/cli/admin/mustgather/mustgather.go
Mutual-exclusivity error string and backup prefix writer text are changed from fmt.Sprintf results to direct string literals; plugin image map retrieval is simplified into a single assignment; a trailing explicit return is removed.
Duration and state string cleanups
pkg/cli/admin/mustgather/summary.go
Duration calculation switches from time.Now().Sub(...) to time.Since(...); the "Unknown state" return is changed from a formatted string to a literal.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing staticcheck warnings in pkg/cli/admin/mustgather.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed No Ginkgo-style test titles were added; the PR only changes non-test files, and existing subtest names in mustgather_test.go are static strings.
Test Structure And Quality ✅ Passed PR only changes non-test mustgather code; package tests are plain testing unit tests with no Ginkgo blocks, so the check is not applicable.
Microshift Test Compatibility ✅ Passed No Ginkgo e2e tests were added or modified; only refactors in non-test mustgather code changed.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The diff only makes mechanical must-gather refactors in two non-test files; no new Ginkgo tests or SNO-unsafe multi-node assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed Only mechanical string/time refactors in mustgather; no pod specs, replicas, affinity, or topology-dependent scheduling logic was added or changed.
Ote Binary Stdout Contract ✅ Passed No process-level main/init/TestMain/BeforeSuite stdout writes were added; the touched code only adjusts command output paths (RawOut/ErrOut) and refactors strings/time.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo/e2e tests were added; only non-test refactors in mustgather.go and summary.go, so IPv4/disconnected compatibility is not applicable.
No-Weak-Crypto ✅ Passed Patch only refactors strings/time in mustgather; no weak algorithms, custom crypto, or secret comparisons were introduced.
Container-Privileges ✅ Passed The PR only makes mechanical refactors in two Go files; no manifests or pod specs add privileged, hostPID/hostIPC, SYS_ADMIN, or allowPrivilegeEscalation settings.
No-Sensitive-Data-In-Logs ✅ Passed Touched code only refactors existing output; no new logs were added and no passwords/tokens/PII/hostnames/customer data are emitted.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tchap

tchap commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@openshift-ci openshift-ci Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 8, 2026
@openshift-ci

openshift-ci Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@ankimaha-sys: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@tchap

tchap commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Thanks!

/lgtm

@tchap

tchap commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 9, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@tchap: This PR has been marked as verified by CI.

Details

In response to this:

/verified by CI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 9, 2026
@openshift-ci

openshift-ci Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ankimaha-sys, tchap
Once this PR has been reviewed and has the lgtm label, please assign ingvagabund for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants