🩹 Fix: golangci-lint issue for go1.25.0#3775
Conversation
|
Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
|
Note Other AI code review bot(s) detectedCodeRabbit 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. WalkthroughAdded an explicit error for unsupported client body types, updated parser to return it; moved session Store fields (Extractor, IdleTimeout) to top-level; upgraded lint tooling; converted many tests to use emptiness/len matchers and modernized goroutine patterns; several small refactors to logging, formatting, routing, and helpers. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant ClientReq as Request
participant Parser
Caller->>ClientReq: parserRequestBody(bodyType)
ClientReq->>Parser: switch by bodyType
alt supported type
Parser-->>ClientReq: parse success (nil)
ClientReq-->>Caller: proceed
else unsupported
Parser-->>ClientReq: ErrBodyTypeNotSupported
ClientReq-->>Caller: return error
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
gaby
left a comment
There was a problem hiding this comment.
The lint workflow in .github/workflows needs to be updated with the new version
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3775 +/- ##
==========================================
+ Coverage 92.02% 92.06% +0.04%
==========================================
Files 115 115
Lines 12249 12257 +8
==========================================
+ Hits 11272 11285 +13
+ Misses 712 709 -3
+ Partials 265 263 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@laughing-nerd The CI is now able to run, can you check the failures |
|
@gaby The failures are due to lint issues in the code. Do you want me to fix them in this PR or raise a separate PR to fix the issues? |
|
In this PR otherwise the default branch is Red. |
There was a problem hiding this comment.
Actionable comments posted: 9
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
middleware/session/session_test.go (1)
1418-1424: Compilation error:sync.WaitGrouphas noGomethod.The code calls
wg.Go(func() { ... })on line 1424, butsync.WaitGroupfrom the standard library does not have aGomethod. This will cause a compilation error.Apply this diff to fix the issue:
for range numGoroutines { - wg.Go(func() { + wg.Add(1) + go func() { defer wg.Done()Alternatively, if you intend to use a helper with a
Gomethod, importgolang.org/x/sync/errgroupand replace:- var wg sync.WaitGroup + var eg errgroup.GroupThen update the loop to use
eg.Goand handle errors appropriately. However, note thaterrgroup.Group.Goexpects a function returningerror, so you'd need to adjust the goroutine body.path.go (1)
516-523: Skip constraints for empty optional parameters. The current checkif !segment.IsOptional || i != 0 { // … }still applies constraints on an empty optional segment (breaking
/api/v1/→params: []string{""}, match: true). Change it to:if !segment.IsOptional || params[paramsIterator] != "" { // … }so constraints run only when a value exists.
🧹 Nitpick comments (3)
path.go (1)
187-190: The early-match change for"/*"is confined toRoutePatternMatch(a standalone helper used only in tests/benchmarks), not the core routing logic. TheRoutePatternMatchhelper isn’t widely exercised for generic wildcard matching inpath_test.go, and its existing tests focus on literal"/*"cases. No tests verify thatRoutePatternMatch("any/path", "/*")returnstrue.This behavior change is intentional (aligns with wildcard semantics) but untested for non-literal paths. Add or update a test in
path_test.go:// in Test_RoutePatternMatch testCaseFn("/*", []routeTestCase{ {url: "/", match: true}, {url: "/foo", match: true}, {url: "/foo/bar", match: true}, })helpers.go (1)
236-236: LGTM! Refactored condition improves readability.The rewritten condition
if rs[0] != "*" && !utils.EqualFold(rs[0], ts[0])is logically equivalent to the originalif !(rs[0] == "*" || utils.EqualFold(rs[0], ts[0]))by De Morgan's law, but is more direct and easier to follow.middleware/logger/tags.go (1)
149-149: LGTM! Direct buffer writes reduce allocations.Replacing
fmt.Sprintfwithfmt.Fprintffor writing formatted output directly to the buffer eliminates intermediate string allocation, improving performance in the logging hot path. The Buffer interface supports this pattern via itsWritemethods.Also applies to: 179-179, 185-185, 192-192, 201-201
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
.github/workflows/linter.ymlis excluded by!**/*.yml.golangci.ymlis excluded by!**/*.yml
📒 Files selected for processing (44)
app_test.go(7 hunks)bind_test.go(4 hunks)binder/binder_test.go(1 hunks)binder/mapping_test.go(1 hunks)client/client_test.go(11 hunks)client/core.go(1 hunks)client/hooks.go(1 hunks)client/hooks_test.go(4 hunks)client/request.go(3 hunks)client/request_test.go(7 hunks)ctx.go(1 hunks)ctx_test.go(18 hunks)extractors/extractors_test.go(2 hunks)helpers.go(2 hunks)helpers_test.go(2 hunks)hooks_test.go(1 hunks)listen.go(2 hunks)listen_test.go(1 hunks)log/default.go(1 hunks)middleware/adaptor/adaptor_test.go(1 hunks)middleware/cache/cache_test.go(1 hunks)middleware/compress/compress_test.go(12 hunks)middleware/cors/cors.go(1 hunks)middleware/cors/cors_test.go(22 hunks)middleware/csrf/config_test.go(1 hunks)middleware/envvar/envvar_test.go(2 hunks)middleware/helmet/helmet_test.go(4 hunks)middleware/idempotency/idempotency_test.go(1 hunks)middleware/keyauth/keyauth_test.go(2 hunks)middleware/limiter/limiter_test.go(7 hunks)middleware/logger/default_logger.go(1 hunks)middleware/logger/logger_test.go(3 hunks)middleware/logger/tags.go(3 hunks)middleware/recover/recover.go(1 hunks)middleware/session/session_test.go(6 hunks)middleware/session/store_test.go(4 hunks)middleware/static/static_test.go(6 hunks)mount_test.go(1 hunks)path.go(5 hunks)path_test.go(1 hunks)req.go(5 hunks)res.go(3 hunks)router_test.go(2 hunks)state_test.go(1 hunks)
✅ Files skipped from review due to trivial changes (4)
- ctx.go
- path_test.go
- app_test.go
- mount_test.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
**/*.go: Format Go code using gofumpt (enforced viamake format)
Ensure code passes golangci-lint checks (enforced viamake lint)
Optimize struct field alignment using betteralign (enforced viamake betteralign)
Modernize Go code using gopls modernize (enforced viamake modernize)
Files:
client/core.gomiddleware/csrf/config_test.gomiddleware/logger/default_logger.gomiddleware/compress/compress_test.goextractors/extractors_test.gopath.gomiddleware/idempotency/idempotency_test.gomiddleware/envvar/envvar_test.gomiddleware/recover/recover.gomiddleware/logger/logger_test.goreq.gorouter_test.goclient/hooks.golog/default.goclient/request.gohelpers_test.gobind_test.goclient/request_test.gomiddleware/adaptor/adaptor_test.gostate_test.goclient/hooks_test.gohelpers.gomiddleware/keyauth/keyauth_test.gobinder/binder_test.gohooks_test.gomiddleware/cors/cors_test.gobinder/mapping_test.gores.gomiddleware/limiter/limiter_test.gomiddleware/session/store_test.gomiddleware/static/static_test.gomiddleware/cache/cache_test.golisten_test.gomiddleware/cors/cors.golisten.gomiddleware/logger/tags.goctx_test.gomiddleware/helmet/helmet_test.gomiddleware/session/session_test.goclient/client_test.go
🧠 Learnings (3)
📚 Learning: 2024-12-13T08:14:22.851Z
Learnt from: efectn
PR: gofiber/fiber#3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the `require` methods from the `testify` package for assertions instead of manual comparisons and calls to `t.Fatal` or `t.Fatalf`.
Applied to files:
client/request_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.
Applied to files:
middleware/cors/cors_test.gomiddleware/session/session_test.go
📚 Learning: 2024-09-25T17:05:06.991Z
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/middleware_test.go:190-191
Timestamp: 2024-09-25T17:05:06.991Z
Learning: When testing session `IdleTimeout` expiration, it's acceptable to use `time.Sleep` to simulate the passage of time in tests.
Applied to files:
middleware/session/session_test.go
🧬 Code graph analysis (16)
middleware/compress/compress_test.go (1)
constants.go (1)
HeaderContentEncoding(212-212)
middleware/logger/logger_test.go (1)
constants.go (1)
MethodGet(5-5)
req.go (1)
constants.go (6)
StatusUnsupportedMediaType(88-88)ErrNotImplemented(149-149)StatusNotImplemented(104-104)StatusBadRequest(73-73)StatusRequestedRangeNotSatisfiable(89-89)HeaderContentRange(234-234)
router_test.go (1)
constants.go (2)
MethodGet(5-5)StatusOK(52-52)
client/hooks.go (1)
client/core.go (1)
ErrBodyTypeNotSupported(256-256)
client/request_test.go (1)
client/request.go (2)
Cookie(778-778)PathParam(826-826)
client/hooks_test.go (1)
client/request.go (2)
Header(708-710)Cookie(778-778)
middleware/cors/cors_test.go (1)
constants.go (6)
HeaderAccessControlAllowCredentials(198-198)HeaderAccessControlMaxAge(203-203)HeaderAccessControlExposeHeaders(202-202)HeaderAccessControlAllowHeaders(199-199)HeaderAccessControlAllowOrigin(201-201)HeaderAccessControlAllowMethods(200-200)
res.go (1)
constants.go (1)
HeaderAccept(190-190)
middleware/limiter/limiter_test.go (1)
constants.go (3)
MethodGet(5-5)StatusOK(52-52)HeaderRetryAfter(273-273)
middleware/session/store_test.go (1)
extractors/extractors.go (1)
Extractor(67-73)
middleware/static/static_test.go (1)
constants.go (2)
HeaderCacheControl(168-168)HeaderContentEncoding(212-212)
middleware/logger/tags.go (3)
middleware/logger/config.go (2)
Buffer(108-119)Config(12-99)ctx_interface_gen.go (1)
Ctx(18-426)middleware/logger/data.go (1)
Data(9-18)
ctx_test.go (3)
req_interface_gen.go (1)
Req(12-188)constants.go (4)
HeaderAccept(190-190)HeaderContentType(216-216)HeaderAcceptLanguage(193-193)HeaderLink(271-271)req.go (1)
Params(619-625)
middleware/helmet/helmet_test.go (1)
constants.go (4)
HeaderContentSecurityPolicy(237-237)HeaderReferrerPolicy(229-229)HeaderPermissionsPolicy(241-241)HeaderStrictTransportSecurity(244-244)
client/client_test.go (1)
client/request.go (2)
Cookie(778-778)PathParam(826-826)
🔇 Additional comments (50)
helpers_test.go (1)
21-21: LGTM! Test assertion improvements align with best practices.The change from
require.Equal(t, "", ...)torequire.Empty(t, ...)improves test readability and semantics.require.Emptyis more expressive and aligns with testifylint recommendations enforced by golangci-lint.Also applies to: 23-23, 25-29, 35-35, 57-58, 63-63, 71-71
middleware/csrf/config_test.go (1)
162-162: LGTM! Idiomatic assertion style.The change from
require.Equal(t, "", chained.Key)torequire.Empty(t, chained.Key)is more idiomatic and aligns with testify best practices for empty-value assertions. This likely addresses a golangci-lint rule (e.g., testifylint) enforcing consistent empty checks.middleware/adaptor/adaptor_test.go (1)
237-237: LGTM!The change from explicit type declaration to short variable declaration is idiomatic Go and aligns with best practices. This likely resolves a golangci-lint warning (e.g., S1021: should omit type from declaration).
middleware/cache/cache_test.go (1)
913-913: LGTM! Test assertion style improved.The change from checking equality with an empty string to using
require.Empty()is more idiomatic for testify assertions and aligns with the PR's objective to address golangci-lint issues. The test logic remains functionally equivalent—both lines correctly verify that HEAD responses return empty bodies per HTTP specification.Also applies to: 920-920
middleware/keyauth/keyauth_test.go (1)
162-163: LGTM! Explicit default case improves clarity.The addition of an explicit default branch for
paramExtractorNamemakes the code more maintainable and satisfies exhaustive switch-case linting rules. Since param-based extraction configures the URL path (lines 132-134) rather than headers or body, this no-op default accurately documents the intentional absence of header/body setup.extractors/extractors_test.go (2)
312-312: LGTM! Improved test assertion.The change from
require.Equal(t, "", ...)torequire.Empty(t, ...)is more idiomatic and aligns with golangci-lint best practices for Go 1.25.0. This assertion style is clearer and handles nil values correctly.
659-659: LGTM! Consistent test assertion improvement.This change mirrors the improvement at line 312, ensuring consistency across the test file. Using
require.Empty(t, ...)is the idiomatic approach for emptiness checks.middleware/envvar/envvar_test.go (2)
24-24: LGTM! Improved assertion style.Using
require.Emptyis more idiomatic than comparing to an empty string and clearly expresses the intent to check for emptiness. This change aligns with testifylint best practices.
119-119: LGTM! Improved assertion style.Using
require.Emptyis more idiomatic than comparing to an empty string. This change clearly expresses the intent to verify that the HEAD request returns no body and aligns with testifylint best practices.middleware/recover/recover.go (1)
11-13: LGTM! Cleaner panic handler implementation.The refactor from
fmt.Sprintf+ write to directfmt.Fprintf(os.Stderr, ...)eliminates an intermediate string allocation and removes the need for thenolint:errcheckdirective. The output remains identical, and the code is now more idiomatic and efficient.res.go (1)
371-371: LGTM: Consistent refactor.The change from
r.c.DefaultReq.Accepts(...)tor.c.Accepts(...)is consistent with the refactoring in theFormatmethod and improves API consistency.middleware/session/store_test.go (2)
22-66: LGTM! Public API field path updated correctly.The test correctly exercises session ID extraction via cookie, header, and URL query using the new top-level
store.Extractor.Keyfield path, aligning with the Store API refactor.
78-93: LGTM! Security regression test updated correctly.The test properly validates that invalid session IDs trigger regeneration, using the updated
store.Extractor.Keyfield path.middleware/session/session_test.go (4)
768-769: LGTM! Public API field path updated correctly.The test correctly forces
IdleTimeoutto a longer value using the new top-levelstore.IdleTimeoutfield to verify thatAbsoluteTimeouttakes precedence, aligning with the Store API refactor.
898-898: LGTM! Improved assertion style.Using
require.Emptyto verify the absence of the session_id header after destruction is more idiomatic than an equality check.
1033-1035: LGTM! Improved cookie attribute validation.Using
strings.SplitSeqwith range iteration to verify cookie attributes order-independently is more robust than substring matching and correctly handles attribute ordering variations.
1182-1183: LGTM! Improved assertion style.Using
require.Emptyto verify the absence of session_id in both response and request headers after reset is more idiomatic than equality checks.path.go (2)
356-364: LGTM! Lint fix for exhaustive switch.The explicit default case satisfies linter requirements (likely exhaustive or similar) without changing behavior. The "do nothing" comment clearly documents the intent.
504-506: LGTM! Improved bounds checking.The condition now explicitly checks
i > partLenbefore slicing, preventing potential out-of-bounds panics. The short-circuit OR operator ensures safe evaluation.hooks_test.go (1)
22-38: LGTM!The assertion update from
require.Equal(t, "", r.Name)torequire.Empty(t, r.Name)improves readability and aligns with idiomatic test style.binder/mapping_test.go (1)
379-398: LGTM!The assertion update from
require.Equal(t, "", m["empty"])torequire.Empty(t, m["empty"])improves readability and aligns with idiomatic test style.middleware/logger/default_logger.go (1)
38-47: LGTM!The refactor from
buf.WriteString(fmt.Sprintf(...))tofmt.Fprintf(buf, ...)reduces allocations by writing directly to the buffer without intermediate string allocation, aligning with other logging components in the repository.binder/binder_test.go (1)
72-83: LGTM!The assertion update from
require.Equal(t, "", m2["empty"])torequire.Empty(t, m2["empty"])improves readability and aligns with idiomatic test style.client/core.go (1)
256-256: LGTM!The new exported error variable
ErrBodyTypeNotSupportedis well-named with a clear error message, enabling explicit error handling for unsupported body types inclient/hooks.go.middleware/static/static_test.go (5)
93-93: LGTM!The assertion update to
require.Emptyfor the Cache-Control header check improves readability and aligns with idiomatic test style.
137-137: LGTM!The assertion update to
require.Emptyfor the Cache-Control header check improves readability and aligns with idiomatic test style.
167-177: LGTM!The assertion updates to
require.Emptyfor the Cache-Control header checks improve readability and align with idiomatic test style.
795-795: LGTM!The assertion update to
require.Emptyfor the Content-Encoding header check improves readability and aligns with idiomatic test style.
826-826: LGTM!The assertion update to
require.Emptyfor the Content-Encoding header check improves readability and aligns with idiomatic test style.middleware/logger/logger_test.go (2)
137-137: LGTM: Test assertion style improvement.The change from
require.Equal(t, "", buf.String())torequire.Empty(t, buf.String())is more idiomatic and aligns with the PR-wide test assertion improvements.
833-835: LGTM: Concurrency pattern modernized.The change from manual
wg.Add(1)andwg.Done()towg.Go(func() {...})is cleaner and less error-prone. This aligns with similar concurrency improvements throughout the test suite.state_test.go (1)
54-54: LGTM: Test assertion style improvements.The changes from
require.Equal(t, "", s)torequire.Empty(t, s)are more idiomatic and align with the PR-wide test assertion improvements. The functional behavior remains unchanged.Also applies to: 59-59
middleware/cors/cors.go (1)
50-50: LGTM: Simplified initialization logic.The change from a two-step initialization to a single boolean expression is cleaner and more concise while maintaining the same logical behavior.
client/request.go (3)
538-547: LGTM: Control flow restructured but functionally equivalent.The switch statement restructuring maintains the same logic:
- Empty name still matches by base path
- Non-empty name matches by equality
- Default case continues iteration
922-922: LGTM: Simplified method call.The change from
f.Args.Del(v)tof.Del(v)is cleaner. SinceFormDatawraps*fasthttp.Argsand likely has aDelmethod that delegates toArgs.Del, this is an improvement.
716-716: Resolve: Header.All() correctly delegates to fasthttp.RequestHeader.All The embedded*fasthttp.RequestHeaderpromotes itsAll()method, soh.All()returns the same data ash.RequestHeader.All().client/request_test.go (1)
459-459: LGTM: Test assertion style improvements.All changes from
require.Equal(t, "", ...)torequire.Empty(t, ...)are more idiomatic and align with the PR-wide test assertion improvements. Based on learnings: prefer usingrequiremethods from the testify package for assertions.Also applies to: 563-563, 578-579, 925-925, 979-979, 1625-1625, 1779-1779
listen_test.go (1)
662-669: LGTM: Concurrency pattern modernized.The change from manual
wg.Add(1)andwg.Done()towg.Go(func() {...})is cleaner and less error-prone. This aligns with similar concurrency improvements throughout the test suite.middleware/compress/compress_test.go (1)
183-183: LGTM: Test assertion style improvements.All changes improve test assertion idioms:
- Replacing
require.Equal(t, "", ...)withrequire.Empty(t, ...)for empty string checks- Replacing
require.Equal(t, len(body), len(filedata))withrequire.Len(t, body, len(filedata))for length checksThese changes align with the PR-wide test assertion improvements and make the test intent clearer.
Also applies to: 188-188, 412-412, 449-449, 471-471, 493-493, 513-513, 532-532, 553-553, 574-574, 595-595, 630-630, 651-651
listen.go (1)
301-302: LGTM! Context-aware listening improves graceful shutdown.Replacing direct
net.Listenwithnet.ListenConfig{}.Listen(cfg.GracefulContext, ...)enables context-aware listener creation for non-TLS paths. This respects cancellation fromcfg.GracefulContextand aligns with the graceful shutdown flow initiated at line 216.helpers.go (1)
447-448: LGTM! Default case documents existing behavior.The added default case explicitly documents that all other characters are ignored in the quoted parsing path. This clarifies intent without changing logic.
router_test.go (1)
1042-1042: LGTM! Empty check is more idiomatic.Replacing the empty string comparison with
require.Emptyis consistent with the broader test suite migration and is more explicit about checking for emptiness.middleware/limiter/limiter_test.go (2)
239-239: LGTM! Usingrequire.NoErrorin goroutines improves test reliability.Switching from
assert.NoErrortorequire.NoErrorinside concurrent test goroutines ensures immediate test failure on error, preventing misleading subsequent assertions and potential race conditions.Also applies to: 243-243, 278-278, 282-282, 320-320, 324-324, 361-361, 365-365
1006-1008: LGTM! Empty checks are more explicit for header absence.Replacing direct empty string comparisons with
require.Emptyfor header checks whenDisableHeadersis true is more idiomatic and clearly expresses the intent that these headers should not be present.Also applies to: 1018-1021
middleware/cors/cors_test.go (1)
51-51: LGTM! Empty checks improve test clarity.Replacing direct empty string comparisons with
require.Emptyfor header assertions is more idiomatic and clearly expresses the intent that these headers should be absent. This aligns with the broader test suite migration to explicit emptiness checks.Also applies to: 83-83, 115-116, 126-127, 184-184, 195-195, 263-263, 364-364, 377-377, 390-390, 532-532, 611-611, 628-628, 643-644, 692-692, 745-745, 1029-1029, 1032-1032, 1042-1042, 1057-1057, 1072-1072, 1088-1088, 1105-1105
middleware/helmet/helmet_test.go (1)
26-26: LGTM! Empty checks are more explicit for header absence.Replacing direct empty string comparisons with
require.Emptyfor security header assertions is more idiomatic and clearly expresses the intent that these headers should be absent in the tested scenarios. This aligns with the broader test suite migration to explicit emptiness checks.Also applies to: 28-28, 83-83, 151-151, 185-185, 233-233
client/hooks_test.go (3)
202-205: LGTM! Default case improves test robustness.Adding a default case with
t.Fatalfensures the test fails immediately if an unexpected query parameter value is encountered, providing clearer diagnostic information and preventing silent test failures.
415-415: LGTM! Empty checks are more idiomatic.Replacing direct empty string comparisons with
require.Emptyfor cookie value assertions is consistent with the broader test suite migration and more clearly expresses the intent.Also applies to: 437-437
624-624: LGTM! Direct buffer write reduces allocations.Replacing
fmt.Sprintfwithfmt.Fprintffor writing formatted logs directly to the buffer eliminates intermediate string allocation, improving efficiency in the test logger.bind_test.go (1)
220-220: LGTM: Idiomatic assertion style.The switch from
require.Equal(t, "", field)torequire.Empty(t, field)improves test readability and aligns with Go testing best practices. This is likely addressing a golangci-lint recommendation for more idiomatic empty-value assertions.Also applies to: 477-477, 1141-1141, 1660-1660
|
/gemini review |
|
some tests are failing locally. Checking the issue. |
There was a problem hiding this comment.
Pull Request Overview
This pull request updates golangci-lint to version 2.5.0 to fix compatibility issues with Go 1.25.0. The update includes migrating the golangci-lint configuration file to the new v2 format and addressing numerous lint violations throughout the codebase.
Key changes include:
- Updated golangci-lint from v1.64.7 to v2.5.0 in Makefile and GitHub Actions workflow
- Migrated
.golangci.ymlconfiguration file to v2 format with restructured settings - Fixed hundreds of lint violations across test files and production code
Reviewed Changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Makefile | Updated golangci-lint version and command path |
| .golangci.yml | Complete migration to v2 configuration format |
| .github/workflows/linter.yml | Updated GitHub Actions to use golangci-lint v2.5.0 |
| Various test files | Replaced require.Equal(t, "", value) with require.Empty(t, value) |
| Production code files | Used fmt.Fprintf instead of manual string formatting, added missing default cases |
There was a problem hiding this comment.
Code Review
This pull request updates golangci-lint to a newer version and applies the necessary configuration changes and code fixes to comply with the new linting rules. The changes are mostly stylistic improvements and modernizations, such as using require.Empty and require.Len in tests, and wg.Go for goroutines. I've found a few issues: a duplicated check in a test, some unreachable code, and a critical deadlock introduced in a test helper function due to incorrect usage of sync.WaitGroup. My review provides suggestions to fix these issues.
|
@laughing-nerd Can you rebase with |
|
@gaby done 👍 |
|
Can someone merge this PR please? Thanks |
|
Sure, tomorrow morning |
|
Great! Thanks! |
ReneWerner87
left a comment
There was a problem hiding this comment.
@laughing-nerd can you check my last hints
|
@ReneWerner87 Sure. I'll make the changes today |
|
@laughing-nerd ping |
|
Oh hey @ReneWerner87 |
Bumps [github.com/shamaton/msgpack/v2](https://github.com/shamaton/msgpack) from 2.3.1 to 2.4.0. - [Release notes](https://github.com/shamaton/msgpack/releases) - [Commits](shamaton/msgpack@v2.3.1...v2.4.0) --- updated-dependencies: - dependency-name: github.com/shamaton/msgpack/v2 dependency-version: 2.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
|
@ReneWerner87 I've made the changes. LMK if anything else needs to be changed |
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
path.go (1)
794-796: Unknown constraints now fail validation (good).Defaulting to
falsefor unspecified IDs is the safe behavior and aligns with custom-constraint override above.
🧹 Nitpick comments (2)
path.go (2)
187-189: Early-match is correct; consider moving before parse for perf.You can short‑circuit before routerParserPool.Get/parseRoute to avoid extra work; functional behavior unchanged.
356-364: GuardparamEndPosition+1to prevent future OOB panics.Current logic is safe given how
paramEndPositionis derived, but a small bound check makes it future‑proof.Apply this diff:
- case bytes.IndexByte(parameterDelimiterChars, pattern[paramEndPosition+1]) == -1: + case (paramEndPosition+1) < len(pattern) && + bytes.IndexByte(parameterDelimiterChars, pattern[paramEndPosition+1]) == -1: paramEndPosition++
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
path.go(5 hunks)req.go(5 hunks)res.go(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- res.go
- req.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
**/*.go: Format Go code using gofumpt (Make target:make format).
Run golangci-lint for linting (Make target:make lint).
Rungo vetas part of audit to catch suspicious constructs (Make target:make audit).
Optimize struct field alignment with betteralign (Make target:make betteralign).
Applygopls modernizeto update code patterns (Make target:make modernize).
Files:
path.go
🔇 Additional comments (2)
path.go (2)
503-506: LGTM: const-part guard with optional slash is correct.The
HasOptionalSlashbranch theni > partLen || detectionPath[:i] != segment.Constfallback reads clean and is correct.
516-524: Skipping constraint checks for omitted optional params is correct.
if !segment.IsOptional || i != 0avoids validating empty optionals (e.g.,:id<int>?). Please ensure tests cover both omitted and present cases with constraints.
|
Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Description
Updated the Makefile to use the latest version of golangci-lint along with necessary migrations. I've followed this migration doc for migrating the old config of golangci-lint.
Fixes #3731
Changes introduced
fixed golangci-lint
updated code to fix lint errors
Benchmarks: Describe any performance benchmarks and improvements related to the changes.
Documentation Update: Detail the updates made to the documentation and links to the changed files.
Changelog/What's New: Include a summary of the additions for the upcoming release notes.
Migration Guide: If necessary, provide a guide or steps for users to migrate their existing code to accommodate these changes.
API Alignment with Express: Explain how the changes align with the Express API.
API Longevity: Discuss the steps taken to ensure that the new or updated APIs are consistent and not prone to breaking changes.
Examples: Provide examples demonstrating the new features or changes in action.
Type of change
Please delete options that are not relevant.
Checklist
Before you submit your pull request, please make sure you meet these requirements:
/docs/directory for Fiber's documentation.Commit formatting
Please use emojis in commit messages for an easy way to identify the purpose or intention of a commit. Check out the emoji cheatsheet here: CONTRIBUTING.md