Skip to content

Update golangci-lint to v2#1637

Merged
Neon-White merged 1 commit intonoobaa:masterfrom
Neon-White:update-golangci-lint-to-v2
Jul 4, 2025
Merged

Update golangci-lint to v2#1637
Neon-White merged 1 commit intonoobaa:masterfrom
Neon-White:update-golangci-lint-to-v2

Conversation

@Neon-White
Copy link
Contributor

@Neon-White Neon-White commented Jun 25, 2025

Explain the changes

1. Updated .golangci.yml to v2 format

  • Added version: "2" at the top to target golangci-lint v2.
  • Replaced the old issues.exclude-dirs/exclude-files keys with a linters.exclusions.paths list for ignoring generated code and CRD packages.
  • Introduced a custom rule to silence ST1005 (text: "ST1005:")

2. Makefile adjustments

  • Now installs golangci-lint/v2 at v2.1.6 if missing or mismatched (required for upgrading pre-existing clones)
  • Supports linting only changed files when FILES is set; falls back to a full run otherwise.

Summary by CodeRabbit

  • Chores
    • Updated linting configuration for improved exclusion handling and compatibility with the latest linter version.
    • Enhanced the linting process in the build system to ensure consistent linter version usage and provide more informative output when linting specific files.

@coderabbitai
Copy link

coderabbitai bot commented Jun 25, 2025

Walkthrough

The .golangci.yml configuration file was updated to version 2 format, restructuring exclusion rules and adding a new staticcheck exclusion. The Makefile's lint target was modified to install a specific version of golangci-lint only when necessary and to conditionally lint either specified files or the entire codebase based on the FILES variable.

Changes

File(s) Change Summary
.golangci.yml Updated to version 2 format; replaced issues exclusions with linters.exclusions; added staticcheck exclusion.
Makefile Modified lint target to install golangci-lint@v2.1.6 only if needed; added logic to lint specific files or all.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Makefile
    participant GolangciLint

    User->>Makefile: make lint (optionally with FILES)
    Makefile->>Makefile: Check if golangci-lint@v2.1.6 is installed
    alt Not installed or wrong version
        Makefile->>GolangciLint: Install golangci-lint@v2.1.6
    end
    alt FILES variable is set
        Makefile->>GolangciLint: Run lint on specified files
    else
        Makefile->>GolangciLint: Run lint on all files
    end
    GolangciLint-->>Makefile: Lint results
    Makefile-->>User: Print lint outcome
Loading

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3878648 and 938eb5c.

📒 Files selected for processing (2)
  • .golangci.yml (1 hunks)
  • Makefile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .golangci.yml
  • Makefile
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: run-operator-tests
  • GitHub Check: run-azure-vault-test
  • GitHub Check: run-kms-tls-token-test
  • GitHub Check: cnpg-deployment-test
  • GitHub Check: run-cli-tests
  • GitHub Check: run-kms-key-rotate-test
  • GitHub Check: run-admission-test
  • GitHub Check: run-kms-dev-test

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 2

🧹 Nitpick comments (1)
.github/workflows/golangci-lint.yml (1)

16-16: Strip trailing spaces – YAML-lint is already failing

Line 16 has two trailing blanks which trip yamllint (trailing-spaces).
They are harmless to GH Actions but will keep the pipeline red.

-  go-version: "1.23.10"··
+  go-version: "1.23.10"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4ce419 and 3878648.

📒 Files selected for processing (4)
  • .github/workflows/golangci-lint.yml (1 hunks)
  • .golangci.yml (1 hunks)
  • Makefile (1 hunks)
  • go.mod (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/golangci-lint.yml

[error] 16-16: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: run-kms-kmip-test
  • GitHub Check: cnpg-deployment-test
  • GitHub Check: run-admission-test
  • GitHub Check: run-cli-tests
  • GitHub Check: run-azure-vault-test
  • GitHub Check: run-core-config-map-tests
  • GitHub Check: run-kms-tls-sa-test
  • GitHub Check: run-kms-dev-test
  • GitHub Check: run-kms-tls-token-test
  • GitHub Check: run-hac-test
  • GitHub Check: run-kms-key-rotate-test
🔇 Additional comments (1)
go.mod (1)

3-3: Verify that pinning the go directive to a patch-level is really required

go 1.23.10 forces all developers and CI images to use exactly ≥ 1.23.10.
Unless you rely on fixes introduced after 1.23.0, the usual practice is to keep only the minor (go 1.23) so that go toolchains resolve to the latest patch automatically.

Please double-check that a patch-level pin is needed (e.g. for a compiler bug) and, if not, consider:

-go 1.23.10
+go 1.23

@Neon-White
Copy link
Contributor Author

The golangci-lint and Run Operator Unit Tests checks are expected to fail until #1636 is merged

@Neon-White Neon-White changed the title Bump go and toolchain versions to 1.23.10, golangci-lint to v2 Update golangci-lint to v2 Jun 26, 2025
@Neon-White Neon-White force-pushed the update-golangci-lint-to-v2 branch from 3958447 to ecbaa3c Compare July 4, 2025 11:48
Signed-off-by: Ben <belimele@redhat.com>
@Neon-White Neon-White force-pushed the update-golangci-lint-to-v2 branch from ecbaa3c to 938eb5c Compare July 4, 2025 11:49
Copy link
Member

@aayushchouhan09 aayushchouhan09 left a comment

Choose a reason for hiding this comment

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

LGTM

@Neon-White Neon-White merged commit dc1f08f into noobaa:master Jul 4, 2025
16 of 17 checks passed
@Neon-White Neon-White deleted the update-golangci-lint-to-v2 branch July 4, 2025 13:06
@coderabbitai coderabbitai bot mentioned this pull request Jul 24, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants