Skip to content

no-jira: Golangci config#10372

Merged
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
patrickdillon:golangci-config
Mar 10, 2026
Merged

no-jira: Golangci config#10372
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
patrickdillon:golangci-config

Conversation

@patrickdillon
Copy link
Contributor

@patrickdillon patrickdillon commented Mar 9, 2026

openshift/release#75091 which is needed to get in go1.25 is showing failures for prealloc. @zaneb pointed out that we don't need it, so let's drop it.

Also let's try to avoid the flakes for var-naming that we're seeing all the time:

#10319 (comment)

Summary by CodeRabbit

  • Chores
    • Updated development tooling configuration to refine code quality checks with improved linting rules.

Prealloc's docs state that using it is an overoptimization. It was
causing some failures in ci rehearsal testing, so let's drop it.
We are frequently seeing a flake for package types:

pkg/types/utils_test.go:1:9: var-naming: avoid meaningless package names (revive)
package types
        ^

Disable this specific linter to avoid these flakes.
@patrickdillon patrickdillon changed the title Golangci config no-jira: Golangci config Mar 9, 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 Mar 9, 2026
@openshift-ci-robot
Copy link
Contributor

@patrickdillon: This pull request explicitly references no jira issue.

Details

In response to this:

openshift/release#75091 which is needed to get in go1.25 is showing failures for prealloc. @zaneb pointed out that we don't need it, so let's drop it.

Also let's try to avoid the flakes for var-naming that we're seeing all the time:

#10319 (comment)

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.

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

Walkthrough

Modified golangci-lint configuration by removing the prealloc linter from global rules and adding a targeted revive linter override for test files with a var-naming check to enforce meaningful package names in test code.

Changes

Cohort / File(s) Summary
Linting Configuration
.golangci-lint-v2.yaml
Removed prealloc linter from global enable list; added per-path override for _test.go files enabling revive with var-naming check for meaningful package names.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'no-jira: Golangci config' is vague and generic, using non-descriptive terms that don't convey the specific changes (removing prealloc linter and disabling var-naming rule). Consider a more specific title like 'Drop prealloc linter and disable var-naming revive rule' or 'Fix golangci-lint flakes by removing prealloc and var-naming checks'.
Test Structure And Quality ❓ Inconclusive This PR modifies only the .golangci-lint-v2.yaml configuration file, adjusting linter rules without any changes to Ginkgo test code or _test.go files. Apply this Ginkgo test quality check only to pull requests that modify actual test code files (ending with _test.go), not linter configuration files.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Stable And Deterministic Test Names ✅ Passed The custom check for stable test names is not applicable; the PR only modifies linter configuration, not Ginkgo test code.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

Copy link

@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-lint-v2.yaml:
- Around line 90-92: The revive exclusion currently listed (linters: revive,
text: "var-naming: avoid meaningless package names") is global; scope it to test
files by adding a path regex that matches _test.go files (e.g. path:
'.*_test\.go$') so the suppression only applies to test-only files; update the
exclusion block containing the revive rule to include that path field while
keeping the existing linters and text entries.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: ef9a81a4-bc52-43ba-a586-61375ba07817

📥 Commits

Reviewing files that changed from the base of the PR and between 4006847 and 4aeaa14.

📒 Files selected for processing (1)
  • .golangci-lint-v2.yaml

Comment on lines +90 to +92
- linters:
- revive
text: "var-naming: avoid meaningless package names"
Copy link

@coderabbitai coderabbitai bot Mar 9, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

In golangci-lint v2, does a linters.exclusions.rulesentry with onlylintersandtextexclude matching issues globally? How should it be scoped so it only applies to_test.go files?

💡 Result:

Yes. In golangci-lint v2, a linters.exclusions.rules item that only specifies linters and text (and no path / path-except) matches all files, so it excludes matching issues “globally” for the selected linters. [1]

To scope it to _test.go files, add a path regex that matches test files, e.g.:

linters:
  exclusions:
    rules:
      - path: '(.+)_test\.go'
        linters: [mnd]          # your linter(s)
        text: "Magic number: 9" # your match text/regex

(path-except is the inverse, i.e., apply the rule everywhere except matching paths.) [1]

Sources: [1] [2]


Scope this revive exclusion to _test.go files.

This exclusion rule specifies only linters and text without a path constraint, which makes it apply globally to all files. In golangci-lint v2, test-only scoping requires adding a path regex. As written, the rule suppresses this warning in all packages, not just test files, which is broader than the PR objective.

Suggested fix
    - linters:
      - revive
      text: "var-naming: avoid meaningless package names"
+   - path: _test\.go
+     linters:
+     - revive
+     text: "var-naming: avoid meaningless package names"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.golangci-lint-v2.yaml around lines 90 - 92, The revive exclusion currently
listed (linters: revive, text: "var-naming: avoid meaningless package names") is
global; scope it to test files by adding a path regex that matches _test.go
files (e.g. path: '.*_test\.go$') so the suppression only applies to test-only
files; update the exclusion block containing the revive rule to include that
path field while keeping the existing linters and text entries.

Copy link
Member

Choose a reason for hiding this comment

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

No, we want to exclude this warning from all packages. This change is correct as intended :D

Copy link

Choose a reason for hiding this comment

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

@tthvo, understood! Thanks for the clarification — suppressing var-naming: avoid meaningless package names globally makes sense since the warning can surface in any package, not just test files. The change is correct as intended. My apologies for the noise!


📝 Learnings were identified and not saved (knowledge base disabled). Enable

Copy link
Member

@tthvo tthvo left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 9, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 9, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tthvo

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 9, 2026
@tthvo
Copy link
Member

tthvo commented Mar 9, 2026

/verified by ci/prow/golint

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

@tthvo: This PR has been marked as verified by [ci/prow/golint](https://prow.ci.openshift.org/view/gs/test-platform-results/pr-logs/pull/openshift_installer/10372/pull-ci-openshift-installer-main-golint/2031110175674339328).

Details

In response to this:

/verified by ci/prow/golint

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.

@zaneb
Copy link
Member

zaneb commented Mar 9, 2026

👍

There's also extensive duplicate linter config in https://github.com/openshift/installer/blob/main/.golangci.yaml - do we know if that gets used for anything any more? Does it need to match, or can it just be deleted at this point?

@tthvo
Copy link
Member

tthvo commented Mar 9, 2026

There's also extensive duplicate linter config in https://github.com/openshift/installer/blob/main/.golangci.yaml - do we know if that gets used for anything any more? Does it need to match, or can it just be deleted at this point?

Oh no, that's the v1 golangci config, which can be safely removed now. We are using v2 golangci lint :D

@tthvo
Copy link
Member

tthvo commented Mar 10, 2026

/retest-required

1 similar comment
@tthvo
Copy link
Member

tthvo commented Mar 10, 2026

/retest-required

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 10, 2026

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

@openshift-merge-bot openshift-merge-bot bot merged commit d3f34bb into openshift:main Mar 10, 2026
16 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. 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. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants