Skip to content

chore: update golangci-lint to v2#1445

Merged
ReneWerner87 merged 3 commits intomainfrom
codex/2025-10-31-13-21-34
Nov 1, 2025
Merged

chore: update golangci-lint to v2#1445
ReneWerner87 merged 3 commits intomainfrom
codex/2025-10-31-13-21-34

Conversation

@ReneWerner87
Copy link
Copy Markdown
Member

@ReneWerner87 ReneWerner87 commented Oct 31, 2025

Summary

  • bump the lint workflow to golangci-lint v2.6.0 and add a shared v2 configuration
  • adjust loadshed, swagger, and websocket helpers to satisfy the updated staticcheck rules

Testing

  • for dir in v3/*; do (cd "$dir" && golangci-lint run ./...); done

https://chatgpt.com/codex/tasks/task_e_6904ae2c3b58832683b34b453eab727c

Summary by CodeRabbit

  • Refactor

    • Improved code style and readability across internal utilities.
    • Enhanced error logging formatting consistency.
  • Chores

    • Internal code maintenance and minor formatting adjustments.

@ReneWerner87 ReneWerner87 requested a review from a team as a code owner October 31, 2025 13:21
@ReneWerner87 ReneWerner87 removed the request for review from a team October 31, 2025 13:21
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 31, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Three files receive minor stylistic refinements: removal of a blank identifier from a method receiver, application of De Morgan's law for clearer conditionals, and modernization of error logging by replacing direct stderr writes with formatted output.

Changes

Cohort / File(s) Change Summary
Method receiver syntax update
v3/loadshed/cpu.go
Removed blank identifier (_) from unnamed receiver in PercentWithContext method of DefaultCPUPercentGetter, improving code style without altering functionality.
Conditional logic reformatting
v3/swagger/swagger.go
Refactored middleware gate condition from negated OR (!(c.Path() == swaggerUIPath || c.Path() == specURL)) to De Morgan's equivalent form (c.Path() != swaggerUIPath && c.Path() != specURL) for improved readability.
Error logging modernization
v3/websocket/websocket.go
Replaced panic error output from os.Stderr.WriteString to fmt.Fprintf for more idiomatic Go error logging while maintaining identical output behavior.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • All changes are cosmetic or style improvements with no functional impact
  • No logic alterations or control-flow modifications
  • Patterns are straightforward and easily verifiable

Suggested reviewers

  • gaby
  • sixcolors
  • efectn

Poem

🐰 A little hop through style and grace,
Blank receivers find their place,
De Morgan's law makes logic bright,
Fprintf logs errors right,
Polish gleams on every trace!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "chore: update golangci-lint to v2" directly and accurately reflects the main objective of the pull request. According to the PR objectives, the primary goal is to bump golangci-lint to v2.6.0 and update the shared configuration, with the three code changes in loadshed, swagger, and websocket serving as necessary adjustments to satisfy the new staticcheck rules in v2. The title is concise, specific, and clearly communicates the core change without vagueness or unnecessary noise.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/2025-10-31-13-21-34

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea13a99 and 4552d47.

⛔ Files ignored due to path filters (2)
  • .github/workflows/golangci-lint.yml is excluded by !**/*.yml
  • v3/.golangci.yml is excluded by !**/*.yml
📒 Files selected for processing (3)
  • v3/loadshed/cpu.go (1 hunks)
  • v3/swagger/swagger.go (1 hunks)
  • v3/websocket/websocket.go (1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: gofiber/fiber PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-22T13:48:12.485Z
Learning: Run golangci-lint (Make target: lint)
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • v3/websocket/websocket.go
📚 Learning: 2025-02-02T23:41:30.921Z
Learnt from: gaby
Repo: gofiber/storage PR: 1562
File: neo4j/neo4j.go:221-221
Timestamp: 2025-02-02T23:41:30.921Z
Learning: In the Neo4j storage implementation, the `mapToStruct` function should return an error instead of panicking when JSON unmarshaling fails to prevent server crashes.

Applied to files:

  • v3/websocket/websocket.go
📚 Learning: 2024-09-25T16:18:34.719Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:122-122
Timestamp: 2024-09-25T16:18:34.719Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.

Applied to files:

  • v3/websocket/websocket.go
📚 Learning: 2025-05-08T08:14:37.302Z
Learnt from: mdelapenya
Repo: gofiber/fiber PR: 3434
File: app.go:623-636
Timestamp: 2025-05-08T08:14:37.302Z
Learning: In the gofiber/fiber framework, service startup failures should panic rather than allowing the application to continue running with degraded functionality, as this is the agreed-upon design decision.

Applied to files:

  • v3/websocket/websocket.go
📚 Learning: 2025-05-01T11:46:33.057Z
Learnt from: gaby
Repo: gofiber/storage PR: 1638
File: surrealdb/surrealdb.go:34-43
Timestamp: 2025-05-01T11:46:33.057Z
Learning: In the gofiber/storage package, storage drivers should panic when encountering database connection failures during initialization rather than returning errors. This is an intentional design pattern to ensure applications fail fast and explicitly when critical database dependencies are unavailable.

Applied to files:

  • v3/websocket/websocket.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: lint (websocket)
  • GitHub Check: lint (swagger)
  • GitHub Check: lint (loadshed)
🔇 Additional comments (3)
v3/swagger/swagger.go (1)

199-199: LGTM: Clearer conditional logic.

The refactor from negated OR to positive AND makes the gate logic more direct and readable.

v3/websocket/websocket.go (1)

69-69: LGTM: More idiomatic error logging.

Using fmt.Fprintf is more efficient and idiomatic than os.Stderr.WriteString(fmt.Sprintf(...)).

v3/loadshed/cpu.go (1)

50-50: LGTM: Proper receiver naming.

Removing the blank identifier aligns with linter expectations for unused receivers.


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 and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ReneWerner87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing code quality and maintainability by upgrading the project's static analysis tool, golangci-lint, to its latest major version (v2.6.0). This upgrade includes the addition of a dedicated configuration file and required small, targeted code modifications across several helper modules to align with the stricter or updated staticcheck rules enforced by the new linter version.

Highlights

  • Linter Upgrade: The project's static analysis tool, golangci-lint, has been updated to version 2.6.0.
  • New Configuration: A shared golangci-lint v2 configuration file (.golangci.yml) has been introduced to standardize linting rules.
  • Code Adjustments: Minor code changes were made in the loadshed, swagger, and websocket modules to comply with the updated static analysis rules enforced by the new linter version.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/golangci-lint.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates golangci-lint and applies the necessary code adjustments to satisfy the new linting rules. The changes in loadshed, swagger, and websocket are positive improvements. I've identified a potential configuration issue in the new .golangci.yml file and a bug in the panic recovery logic within the websocket package that could affect error reporting. My detailed feedback is in the comments below.

@ReneWerner87 ReneWerner87 merged commit cf55182 into main Nov 1, 2025
10 checks passed
@ReneWerner87 ReneWerner87 deleted the codex/2025-10-31-13-21-34 branch November 1, 2025 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant