Skip to content

CNF-23397: Upgrade golangci-lint from v1.64.8 to v2.11.4#576

Open
sebrandon1 wants to merge 1 commit intoopenshift:mainfrom
sebrandon1:golangci-lint-v2-upgrade
Open

CNF-23397: Upgrade golangci-lint from v1.64.8 to v2.11.4#576
sebrandon1 wants to merge 1 commit intoopenshift:mainfrom
sebrandon1:golangci-lint-v2-upgrade

Conversation

@sebrandon1
Copy link
Copy Markdown
Member

@sebrandon1 sebrandon1 commented Jan 16, 2026

Summary

  • Update golangci-lint from v1.64.8 to v2.0.2
  • Migrate .golangci.yml to v2 format

Changes Made

  • Makefile: Updated version variable
  • .golangci.yml: Converted to v2 format with proper structure

Test plan

  • CI linting passes with golangci-lint v2
  • No new linting errors introduced

Tracking: redhat-best-practices-for-k8s/telco-bot#49

Summary by CodeRabbit

  • Chores

    • Migrated linter configuration to the v2 format, adjusted enabled checks, added explicit per-check exclusions, and pinned the linter tool to a newer v2 release for linting runs.
  • Tests

    • Removed an unused test helper to clean up and simplify test code.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Jan 16, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sebrandon1
Once this PR has been reviewed and has the lgtm label, please assign marioferh 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

@simonpasquier
Copy link
Copy Markdown
Contributor

The new linter requires some code changes.

@sebrandon1 sebrandon1 force-pushed the golangci-lint-v2-upgrade branch from a1cba07 to e789919 Compare January 19, 2026 15:13
@sebrandon1
Copy link
Copy Markdown
Member Author

I've fixed the linter failures by updating the .golangci.yml configuration for v2 compatibility:

  • Added proper exclude-functions for errcheck to handle Close(), Log(), and fmt.Fprintln calls
  • Configured govet.disable for testinggoroutine (v2 format)
  • Added staticcheck.checks to disable checks that weren't enforced in v1 (SA2002, SA1019, SA4006, SA4001, ST1000, ST1005, ST1020, QF1002)
  • Removed unused testCloser type from pkg/runutil/runutil_test.go

The ci/prow/lint job is now passing ✅

@simonpasquier
Copy link
Copy Markdown
Contributor

I'd prefer to fix the linter issues first then update the linter version.

@sebrandon1
Copy link
Copy Markdown
Member Author

sebrandon1 commented Jan 19, 2026

So I've been messing with v1 and I don't believe it was failing in v1. v2 has some newer/stricter/updated checks so its possible that v1 was passing just fine but v2 is now flagging the code as having linter errors which I fixed here.

Comment thread .golangci.yml
- unused
linters-settings:
errcheck:
exclude: .errcheck_excludes.txt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove that file?

@sebrandon1 sebrandon1 force-pushed the golangci-lint-v2-upgrade branch from e789919 to be7d6f9 Compare April 17, 2026 13:03
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a029d997-d9ea-4228-b27a-e105953477ad

📥 Commits

Reviewing files that changed from the base of the PR and between 4c38ed4 and bf1f6eb.

📒 Files selected for processing (3)
  • .golangci.yml
  • Makefile
  • pkg/runutil/runutil_test.go
💤 Files with no reviewable changes (1)
  • pkg/runutil/runutil_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • Makefile

Walkthrough

Migrate golangci-lint config to v2 format and enable/configure v2 linters; bump golangci-lint version in Makefile; remove an unused test helper from pkg/runutil/runutil_test.go.

Changes

golangci-lint configuration

Layer / File(s) Summary
Config Version & Shape
.golangci.yml
Change config to version: "2" and introduce nested linters.settings structure.
Linter Settings
.golangci.yml
Move govet, enable staticcheck and unused, configure staticcheck to run all checks while disabling specific checks, add errcheck.exclude-functions list (replace file-based excludes).
Tooling Pin
Makefile
Bump GOLANGCI_LINT_VERSION from v1.64.8 to v2.11.4 so CI/local lint uses golangci-lint v2.

Test cleanup

Layer / File(s) Summary
Test code removal
pkg/runutil/runutil_test.go
Remove unused testCloser type and its Close() error method from test file.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 12
✅ Passed checks (12 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: upgrading golangci-lint from v1.64.8 to v2.11.4, with necessary configuration migration.
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 The PR does not involve Ginkgo tests. The codebase uses standard Go testing, not Ginkgo BDD framework. The check is not applicable to this PR.
Test Structure And Quality ✅ Passed The custom check for Ginkgo test code is not applicable. The repository uses standard Go testing (testing.T), not Ginkgo. No Ginkgo tests exist. The PR only modifies linter config and Makefile.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests added. PR only contains golangci-lint config migration, Makefile version pin, and unit test cleanup. Check not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR upgrades golangci-lint v1 to v2 and does not add any new Ginkgo e2e tests. Check not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only linter configuration, build tool version, and test cleanup—not deployment manifests, operator code, or controllers. The scheduling constraint check does not apply.
Ote Binary Stdout Contract ✅ Passed PR contains only config changes (.golangci.yml, Makefile) and test-only cleanup. No modifications to production code or process-level stdout. Cannot violate OTE Binary Stdout Contract.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR contains no new Ginkgo e2e tests. Changes are linter configuration upgrades (.golangci.yml, Makefile) and removal of unused test helper code in a standard Go unit test. Check is not applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.golangci.yml:
- Around line 9-16: Unify the errcheck exclusions by either adding the
vendor-path logger exclusion
(github.com/openshift/telemeter/vendor/github.com/go-kit/log.Logger).Log to the
existing errcheck exclusions block (the same place that lists
(github.com/go-kit/log.Logger).Log and other Close/Fprintf entries) or remove
the legacy errcheck exclusions file so there’s a single source of truth; ensure
the exact vendor-path symbol is present in the exclusions to match the
vendorized import.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1fab9657-ab63-47c4-9253-41c43affa581

📥 Commits

Reviewing files that changed from the base of the PR and between d6c7dd4 and be7d6f9.

📒 Files selected for processing (3)
  • .golangci.yml
  • Makefile
  • pkg/runutil/runutil_test.go
💤 Files with no reviewable changes (1)
  • pkg/runutil/runutil_test.go

Comment thread .golangci.yml
@sebrandon1 sebrandon1 force-pushed the golangci-lint-v2-upgrade branch from be7d6f9 to 4c38ed4 Compare April 30, 2026 19:28
@sebrandon1 sebrandon1 changed the title Upgrade golangci-lint from v1 to v2 Upgrade golangci-lint from v1.64.8 to v2.11.4 Apr 30, 2026
@sebrandon1 sebrandon1 changed the title Upgrade golangci-lint from v1.64.8 to v2.11.4 CNF-23397: Upgrade golangci-lint from v1.64.8 to v2.11.4 Apr 30, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 30, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented Apr 30, 2026

@sebrandon1: This pull request references CNF-23397 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Update golangci-lint from v1.64.8 to v2.0.2
  • Migrate .golangci.yml to v2 format

Changes Made

  • Makefile: Updated version variable
  • .golangci.yml: Converted to v2 format with proper structure

Test plan

  • CI linting passes with golangci-lint v2
  • No new linting errors introduced

Tracking: redhat-best-practices-for-k8s/telco-bot#49

Summary by CodeRabbit

  • Chores

  • Migrated linter configuration to the v2 format, adjusted enabled checks and explicit exclusions, and pinned the linter tool to a newer v2 release for linting runs.

  • Tests

  • Removed an unused test helper utility to clean up test code.

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.

- Update GOLANGCI_LINT_VERSION from v1.64.8 to v2.0.2
- Migrate .golangci.yml to v2 format:
  - Add version: "2" declaration
  - Move linters-settings under linters.settings

Tracking: redhat-best-practices-for-k8s/telco-bot#49
@sebrandon1 sebrandon1 force-pushed the golangci-lint-v2-upgrade branch from 4c38ed4 to bf1f6eb Compare May 5, 2026 22:37
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 6, 2026

@sebrandon1: 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.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants