Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ enhancement: use msgp for flash message encoding/decoding #3099

Merged
merged 9 commits into from
Aug 29, 2024

Conversation

efectn
Copy link
Member

@efectn efectn commented Aug 10, 2024

Description

Replace current redirection serialization with msgp which is more performant and gives more readable, clean code.

Old Benchmarks:

Benchmark_Redirect_Route-4                                                                    	 6814248	       176.5 ns/op	      16 B/op	       1 allocs/op
Benchmark_Redirect_Route_WithQueries-4                                                        	 3426120	       346.7 ns/op	      16 B/op	       1 allocs/op
Benchmark_Redirect_Route_WithFlashMessages-4                                                  	 3366782	       354.8 ns/op	      32 B/op	       3 allocs/op
Benchmark_Redirect_parseAndClearFlashMessages-4                                               	 1254584	       875.1 ns/op	     820 B/op	       0 allocs/op
Benchmark_Redirect_processFlashMessages-4                                                     	387093091	         3.109 ns/op	       0 B/op	       0 allocs/op
Benchmark_Redirect_Messages-4                                                                 	 4232792	       281.7 ns/op	     336 B/op	       2 allocs/op
Benchmark_Redirect_OldInputs-4                                                                	 4164416	       285.3 ns/op	     336 B/op	       2 allocs/op
Benchmark_Redirect_Message-4                                                                  	24883599	        48.05 ns/op	       0 B/op	       0 allocs/op
Benchmark_Redirect_OldInput-4                                                                 	16826005	        71.45 ns/op	       0 B/op	       0 allocs/op

New Benchmarks:

Benchmark_Redirect_Route-16                         	 9088268	       134.8 ns/op	      16 B/op	       1 allocs/op
Benchmark_Redirect_Route_WithQueries-16             	 3843570	       315.5 ns/op	      16 B/op	       1 allocs/op
Benchmark_Redirect_Route_WithFlashMessages-16       	 4386789	       281.6 ns/op	     117 B/op	       2 allocs/op
Benchmark_Redirect_parseAndClearFlashMessages-16    	 5126095	       228.3 ns/op	      32 B/op	       6 allocs/op
Benchmark_Redirect_processFlashMessages-16          	 7152108	       168.3 ns/op	     112 B/op	       1 allocs/op
Benchmark_Redirect_Messages-16                      	13430538	        93.27 ns/op	     128 B/op	       2 allocs/op
Benchmark_Redirect_OldInputs-16                     	13147718	        83.52 ns/op	      96 B/op	       2 allocs/op
Benchmark_Redirect_Message-16                       	99072417	        11.68 ns/op	       0 B/op	       0 allocs/op
Benchmark_Redirect_OldInput-16                      	175335772	         7.149 ns/op	       0 B/op	       0 allocs/op

Note: Old Benchmark_Redirect_processFlashMessages benchmark is wrong as https://github.com/gofiber/fiber/blob/main/redirect.go#L278 causes its to execute effectively just for once. Right benchmark result is:
Benchmark_Redirect_processFlashMessages-16 9702147 122.6 ns/op 0 B/op 0 allocs/op

Changes introduced

  • Benchmarks: Describe any performance benchmarks and improvements related to the changes.

Type of change

  • Enhancement (improvement to existing features and functionality)
  • Performance improvement (non-breaking change which improves efficiency)
  • Code consistency (non-breaking change which improves code reliability and robustness)

Checklist

  • Followed the inspiration of the Express.js framework for new functionalities, making them similar in usage.
  • Conducted a self-review of the code and provided comments for complex or critical parts.
  • Updated the documentation in the /docs/ directory for Fiber's documentation.
  • Added or updated unit tests to validate the effectiveness of the changes or new features.
  • Ensured that new and existing unit tests pass locally with the changes.
  • Verified that any new dependencies are essential and have been agreed upon by the maintainers/community.
  • Aimed for optimal performance with minimal allocations in the new code.
  • Provided benchmarks for the new code to analyze and improve upon.

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

@efectn efectn requested a review from a team as a code owner August 10, 2024 14:24
@efectn efectn requested review from gaby, sixcolors and ReneWerner87 and removed request for a team August 10, 2024 14:24
Copy link
Contributor

coderabbitai bot commented Aug 10, 2024

Walkthrough

This update modifies the internal message management within the ctx.go, redirect.go, and newly added redirect_msgp.go files. The DefaultCtx struct now utilizes flashMessages instead of redirectionMessages, while the Redirect struct employs a new unified structure for managing flash messages and old input data. Additionally, serialization and deserialization logic for these messages has been implemented, accompanied by comprehensive tests to validate functionality.

Changes

Files Change Summary
ctx.go, redirect.go Modified message handling in DefaultCtx and Redirect structs to incorporate flashMessages and redirectionMsgs. Updated method signatures to accommodate new data structures.
redirect_msgp.go Introduced serialization and deserialization for redirectionMsg and redirectionMsgs using MessagePack format.
redirect_msgp_test.go Added tests for serialization and deserialization processes of redirectionMsg and redirectionMsgs, ensuring data integrity and performance.
redirect_test.go Enhanced tests for redirect handling to utilize new message structures, ensuring correct management of flash messages and old input data.
middleware/* Updated go:generate directives across various files to specify output filenames and include testing options for the msgp tool.

Sequence Diagram(s)

sequenceDiagram
    participant C as Ctx
    participant R as Redirect
    participant M as Messages
    participant S as Serializer

    C->>R: Redirect()
    R->>M: With(key, value, level)
    M->>S: MarshalMsg()
    S-->>M: Encoded data
    M-->>R: Set messages
    R-->>C: Return Redirect
Loading

🐇 In the meadow, changes bloom bright,
New messages hop, bringing delight!
With levels and flashes, a vibrant display,
Our code dances forward, hip-hip-hooray!
Hopping along with joy and cheer,
Together we code, year after year! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

codecov bot commented Aug 10, 2024

Codecov Report

Attention: Patch coverage is 62.25681% with 97 lines in your changes missing coverage. Please review.

Project coverage is 80.03%. Comparing base (25e3992) to head (da8473c).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
redirect_msgp.go 49.72% 65 Missing and 28 partials ⚠️
redirect.go 94.36% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3099      +/-   ##
==========================================
- Coverage   80.77%   80.03%   -0.75%     
==========================================
  Files         116      117       +1     
  Lines        8850     9041     +191     
==========================================
+ Hits         7149     7236      +87     
- Misses       1302     1374      +72     
- Partials      399      431      +32     
Flag Coverage Δ
unittests 80.03% <62.25%> (-0.75%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@efectn efectn force-pushed the redirect-msgp-v3 branch 2 times, most recently from 1f11d67 to 58bb4d4 Compare August 10, 2024 14:30
Copy link
Contributor

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

Caution

Inline review comments failed to post

Actionable comments posted: 16

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e437633 and 9655c30.

Files selected for processing (4)
  • ctx.go (2 hunks)
  • redirect.go (7 hunks)
  • redirect_msgp.go (1 hunks)
  • redirect_test.go (19 hunks)
Additional context used
GitHub Check: codecov/patch
redirect_msgp.go

[warning] 10-17: redirect_msgp.go#L10-L17
Added lines #L10 - L17 were not covered by tests


[warning] 19-24: redirect_msgp.go#L19-L24
Added lines #L19 - L24 were not covered by tests


[warning] 26-31: redirect_msgp.go#L26-L31
Added lines #L26 - L31 were not covered by tests


[warning] 33-37: redirect_msgp.go#L33-L37
Added lines #L33 - L37 were not covered by tests


[warning] 39-43: redirect_msgp.go#L39-L43
Added lines #L39 - L43 were not covered by tests


[warning] 45-49: redirect_msgp.go#L45-L49
Added lines #L45 - L49 were not covered by tests


[warning] 51-55: redirect_msgp.go#L51-L55
Added lines #L51 - L55 were not covered by tests


[warning] 59-59: redirect_msgp.go#L59
Added line #L59 was not covered by tests


[warning] 63-63: redirect_msgp.go#L63
Added line #L63 was not covered by tests


[warning] 66-68: redirect_msgp.go#L66-L68
Added lines #L66 - L68 were not covered by tests


[warning] 70-73: redirect_msgp.go#L70-L73
Added lines #L70 - L73 were not covered by tests


[warning] 76-78: redirect_msgp.go#L76-L78
Added lines #L76 - L78 were not covered by tests


[warning] 80-83: redirect_msgp.go#L80-L83
Added lines #L80 - L83 were not covered by tests


[warning] 86-88: redirect_msgp.go#L86-L88
Added lines #L86 - L88 were not covered by tests


[warning] 90-93: redirect_msgp.go#L90-L93
Added lines #L90 - L93 were not covered by tests


[warning] 96-98: redirect_msgp.go#L96-L98
Added lines #L96 - L98 were not covered by tests


[warning] 100-103: redirect_msgp.go#L100-L103
Added lines #L100 - L103 were not covered by tests


[warning] 105-105: redirect_msgp.go#L105
Added line #L105 was not covered by tests


[warning] 134-135: redirect_msgp.go#L134-L135
Added lines #L134 - L135 were not covered by tests


[warning] 141-142: redirect_msgp.go#L141-L142
Added lines #L141 - L142 were not covered by tests


[warning] 148-149: redirect_msgp.go#L148-L149
Added lines #L148 - L149 were not covered by tests


[warning] 154-155: redirect_msgp.go#L154-L155
Added lines #L154 - L155 were not covered by tests


[warning] 160-161: redirect_msgp.go#L160-L161
Added lines #L160 - L161 were not covered by tests


[warning] 166-167: redirect_msgp.go#L166-L167
Added lines #L166 - L167 were not covered by tests

redirect.go

[warning] 140-140: redirect.go#L140
Added line #L140 was not covered by tests


[warning] 142-142: redirect.go#L142
Added line #L142 was not covered by tests


[warning] 190-190: redirect.go#L190
Added line #L190 was not covered by tests


[warning] 222-222: redirect.go#L222
Added line #L222 was not covered by tests


[warning] 295-295: redirect.go#L295
Added line #L295 was not covered by tests


[warning] 308-308: redirect.go#L308
Added line #L308 was not covered by tests

golangci-lint
redirect_test.go

49-49: len: use require.Len

(testifylint)


192-192: len: use require.Len

(testifylint)


239-239: len: use require.Len

(testifylint)


267-267: len: use require.Len

(testifylint)


538-538: len: use require.Len

(testifylint)

GitHub Check: lint
redirect_test.go

[failure] 49-49:
len: use require.Len (testifylint)


[failure] 192-192:
len: use require.Len (testifylint)


[failure] 239-239:
len: use require.Len (testifylint)


[failure] 267-267:
len: use require.Len (testifylint)


[failure] 538-538:
len: use require.Len (testifylint)

Additional comments not posted (27)
redirect_msgp.go (10)

10-59: LGTM!

The DecodeMsg function is implemented correctly with proper error handling.

Tools
GitHub Check: codecov/patch

[warning] 10-17: redirect_msgp.go#L10-L17
Added lines #L10 - L17 were not covered by tests


[warning] 19-24: redirect_msgp.go#L19-L24
Added lines #L19 - L24 were not covered by tests


[warning] 26-31: redirect_msgp.go#L26-L31
Added lines #L26 - L31 were not covered by tests


[warning] 33-37: redirect_msgp.go#L33-L37
Added lines #L33 - L37 were not covered by tests


[warning] 39-43: redirect_msgp.go#L39-L43
Added lines #L39 - L43 were not covered by tests


[warning] 45-49: redirect_msgp.go#L45-L49
Added lines #L45 - L49 were not covered by tests


[warning] 51-55: redirect_msgp.go#L51-L55
Added lines #L51 - L55 were not covered by tests


[warning] 59-59: redirect_msgp.go#L59
Added line #L59 was not covered by tests


63-105: LGTM!

The EncodeMsg function is implemented correctly with proper error handling.

Tools
GitHub Check: codecov/patch

[warning] 63-63: redirect_msgp.go#L63
Added line #L63 was not covered by tests


[warning] 66-68: redirect_msgp.go#L66-L68
Added lines #L66 - L68 were not covered by tests


[warning] 70-73: redirect_msgp.go#L70-L73
Added lines #L70 - L73 were not covered by tests


[warning] 76-78: redirect_msgp.go#L76-L78
Added lines #L76 - L78 were not covered by tests


[warning] 80-83: redirect_msgp.go#L80-L83
Added lines #L80 - L83 were not covered by tests


[warning] 86-88: redirect_msgp.go#L86-L88
Added lines #L86 - L88 were not covered by tests


[warning] 90-93: redirect_msgp.go#L90-L93
Added lines #L90 - L93 were not covered by tests


[warning] 96-98: redirect_msgp.go#L96-L98
Added lines #L96 - L98 were not covered by tests


[warning] 100-103: redirect_msgp.go#L100-L103
Added lines #L100 - L103 were not covered by tests


[warning] 105-105: redirect_msgp.go#L105
Added line #L105 was not covered by tests


109-125: LGTM!

The MarshalMsg function is implemented correctly.


128-179: LGTM!

The UnmarshalMsg function is implemented correctly.

Tools
GitHub Check: codecov/patch

[warning] 134-135: redirect_msgp.go#L134-L135
Added lines #L134 - L135 were not covered by tests


[warning] 141-142: redirect_msgp.go#L141-L142
Added lines #L141 - L142 were not covered by tests


[warning] 148-149: redirect_msgp.go#L148-L149
Added lines #L148 - L149 were not covered by tests


[warning] 154-155: redirect_msgp.go#L154-L155
Added lines #L154 - L155 were not covered by tests


[warning] 160-161: redirect_msgp.go#L160-L161
Added lines #L160 - L161 were not covered by tests


[warning] 166-167: redirect_msgp.go#L166-L167
Added lines #L166 - L167 were not covered by tests


181-185: LGTM!

The Msgsize function correctly estimates the size of the serialized message.


188-207: LGTM!

The DecodeMsg function for redirectionMsgs is implemented correctly.


210-224: LGTM!

The EncodeMsg function for redirectionMsgs is implemented correctly.


228-239: LGTM!

The MarshalMsg function for redirectionMsgs is implemented correctly.


242-263: LGTM!

The UnmarshalMsg function for redirectionMsgs is implemented correctly.


266-271: LGTM!

The Msgsize function for redirectionMsgs correctly estimates the size of the serialized message.

redirect.go (9)

21-21: LGTM!

The addition of the messages field to the Redirect struct is consistent with the new flash message handling approach.

Also applies to: 62-64


112-123: LGTM!

The With method correctly handles the optional level parameter for flash messages.


137-153: LGTM!

The WithInput method correctly processes and appends old input data.

Tools
GitHub Check: codecov/patch

[warning] 140-140: redirect.go#L140
Added line #L140 was not covered by tests


[warning] 142-142: redirect.go#L142
Added line #L142 was not covered by tests


160-172: LGTM!

The Messages method correctly retrieves and constructs flash messages.


177-190: LGTM!

The Message method correctly retrieves a flash message by key.

Tools
GitHub Check: codecov/patch

[warning] 190-190: redirect.go#L190
Added line #L190 was not covered by tests


194-206: LGTM!

The OldInputs method correctly retrieves and constructs old input data.


210-222: LGTM!

The OldInput method correctly retrieves old input data by key.

Tools
GitHub Check: codecov/patch

[warning] 222-222: redirect.go#L222
Added line #L222 was not covered by tests


288-297: LGTM!

The parseAndClearFlashMessages method correctly parses flash messages from cookies.

Tools
GitHub Check: codecov/patch

[warning] 295-295: redirect.go#L295
Added line #L295 was not covered by tests


302-315: LGTM!

The processFlashMessages method correctly processes and sets flash messages as cookies.

Tools
GitHub Check: codecov/patch

[warning] 308-308: redirect.go#L308
Added line #L308 was not covered by tests

redirect_test.go (6)

285-357: LGTM!

The Test_Redirect_parseAndClearFlashMessages test case correctly verifies parsing and clearing of flash messages.


Line range hint 372-410:
LGTM!

The Benchmark_Redirect_Route benchmark correctly measures the performance of route redirection.


Line range hint 413-455:
LGTM!

The Benchmark_Redirect_Route_WithQueries benchmark correctly measures the performance of route redirection with queries.


Line range hint 589-612:
LGTM!

The Benchmark_Redirect_OldInputs benchmark correctly measures the performance of retrieving old input data.


Line range hint 624-643:
LGTM!

The Benchmark_Redirect_Message benchmark correctly measures the performance of retrieving a flash message.


Line range hint 655-673:
LGTM!

The Benchmark_Redirect_OldInput benchmark correctly measures the performance of retrieving old input data by key.

ctx.go (2)

70-70: Introduction of flashMessages field in DefaultCtx.

The addition of flashMessages of type redirectionMsgs in the DefaultCtx struct aligns with the PR objectives to enhance message handling. This change is consistent with the shift towards using msgp for encoding/decoding flash messages.


1899-1899: Update in release method to reset flashMessages.

The release method now correctly resets flashMessages, which aligns with the structural changes in DefaultCtx. This ensures that flash messages are cleared appropriately, maintaining the integrity of the context's state.

Comments failed to post (16)
redirect_msgp.go

10-59: Reminder: Add tests for DecodeMsg.

The DecodeMsg function is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 10-17: redirect_msgp.go#L10-L17
Added lines #L10 - L17 were not covered by tests


[warning] 19-24: redirect_msgp.go#L19-L24
Added lines #L19 - L24 were not covered by tests


[warning] 26-31: redirect_msgp.go#L26-L31
Added lines #L26 - L31 were not covered by tests


[warning] 33-37: redirect_msgp.go#L33-L37
Added lines #L33 - L37 were not covered by tests


[warning] 39-43: redirect_msgp.go#L39-L43
Added lines #L39 - L43 were not covered by tests


[warning] 45-49: redirect_msgp.go#L45-L49
Added lines #L45 - L49 were not covered by tests


[warning] 51-55: redirect_msgp.go#L51-L55
Added lines #L51 - L55 were not covered by tests


[warning] 59-59: redirect_msgp.go#L59
Added line #L59 was not covered by tests


63-105: Reminder: Add tests for EncodeMsg.

The EncodeMsg function is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 63-63: redirect_msgp.go#L63
Added line #L63 was not covered by tests


[warning] 66-68: redirect_msgp.go#L66-L68
Added lines #L66 - L68 were not covered by tests


[warning] 70-73: redirect_msgp.go#L70-L73
Added lines #L70 - L73 were not covered by tests


[warning] 76-78: redirect_msgp.go#L76-L78
Added lines #L76 - L78 were not covered by tests


[warning] 80-83: redirect_msgp.go#L80-L83
Added lines #L80 - L83 were not covered by tests


[warning] 86-88: redirect_msgp.go#L86-L88
Added lines #L86 - L88 were not covered by tests


[warning] 90-93: redirect_msgp.go#L90-L93
Added lines #L90 - L93 were not covered by tests


[warning] 96-98: redirect_msgp.go#L96-L98
Added lines #L96 - L98 were not covered by tests


[warning] 100-103: redirect_msgp.go#L100-L103
Added lines #L100 - L103 were not covered by tests


[warning] 105-105: redirect_msgp.go#L105
Added line #L105 was not covered by tests


109-125: Reminder: Add tests for MarshalMsg.

The MarshalMsg function is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?


128-179: Reminder: Add tests for UnmarshalMsg.

The UnmarshalMsg function is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 134-135: redirect_msgp.go#L134-L135
Added lines #L134 - L135 were not covered by tests


[warning] 141-142: redirect_msgp.go#L141-L142
Added lines #L141 - L142 were not covered by tests


[warning] 148-149: redirect_msgp.go#L148-L149
Added lines #L148 - L149 were not covered by tests


[warning] 154-155: redirect_msgp.go#L154-L155
Added lines #L154 - L155 were not covered by tests


[warning] 160-161: redirect_msgp.go#L160-L161
Added lines #L160 - L161 were not covered by tests


[warning] 166-167: redirect_msgp.go#L166-L167
Added lines #L166 - L167 were not covered by tests


188-207: Reminder: Add tests for DecodeMsg on redirectionMsgs.

The DecodeMsg function is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?


210-224: Reminder: Add tests for EncodeMsg on redirectionMsgs.

The EncodeMsg function is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?


228-239: Reminder: Add tests for MarshalMsg on redirectionMsgs.

The MarshalMsg function is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?


242-263: Reminder: Add tests for UnmarshalMsg on redirectionMsgs.

The UnmarshalMsg function is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

redirect.go

137-145: Reminder: Add tests for WithInput.

Some lines in the WithInput method are not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 140-140: redirect.go#L140
Added line #L140 was not covered by tests


[warning] 142-142: redirect.go#L142
Added line #L142 was not covered by tests


288-295: Reminder: Add tests for parseAndClearFlashMessages.

The error handling in the parseAndClearFlashMessages method is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 295-295: redirect.go#L295
Added line #L295 was not covered by tests


302-308: Reminder: Add tests for processFlashMessages.

The error handling in the processFlashMessages method is not covered by tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 308-308: redirect.go#L308
Added line #L308 was not covered by tests

redirect_test.go

49-49: Use require.Len for length checks.

Replace the require.Equal for length checks with require.Len for better readability.

- require.Equal(t, 2, len(msgs))
+ require.Len(t, msgs, 2)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	require.Len(t, msgs, 2)
Tools
golangci-lint

49-49: len: use require.Len

(testifylint)

GitHub Check: lint

[failure] 49-49:
len: use require.Len (testifylint)


239-239: Use require.Len for length checks.

Replace the require.Equal for length checks with require.Len for better readability.

- require.Equal(t, 2, len(msgs))
+ require.Len(t, msgs, 2)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	require.Len(t, msgs, 2)
Tools
golangci-lint

239-239: len: use require.Len

(testifylint)

GitHub Check: lint

[failure] 239-239:
len: use require.Len (testifylint)


192-192: Use require.Len for length checks.

Replace the require.Equal for length checks with require.Len for better readability.

- require.Equal(t, 2, len(msgs))
+ require.Len(t, msgs, 2)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	require.Len(t, msgs, 2)
Tools
golangci-lint

192-192: len: use require.Len

(testifylint)

GitHub Check: lint

[failure] 192-192:
len: use require.Len (testifylint)


267-267: Use require.Len for length checks.

Replace the require.Equal for length checks with require.Len for better readability.

- require.Equal(t, 4, len(msgs))
+ require.Len(t, msgs, 4)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	require.Len(t, msgs, 4)
Tools
golangci-lint

267-267: len: use require.Len

(testifylint)

GitHub Check: lint

[failure] 267-267:
len: use require.Len (testifylint)


538-538: Use require.Len for length checks.

Replace the require.Equal for length checks with require.Len for better readability.

- require.Equal(b, 2, len(msgs))
+ require.Len(b, msgs, 2)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	require.Len(b, msgs, 2)
Tools
golangci-lint

538-538: len: use require.Len

(testifylint)

GitHub Check: lint

[failure] 538-538:
len: use require.Len (testifylint)

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: 2a73d5a Previous: e437633 Ratio
Benchmark_Redirect_Route_WithFlashMessages - B/op 117 B/op 32 B/op 3.66
Benchmark_Redirect_parseAndClearFlashMessages - allocs/op 6 allocs/op 0 allocs/op +∞
Benchmark_Redirect_processFlashMessages 228.8 ns/op 112 B/op 1 allocs/op 3.109 ns/op 0 B/op 0 allocs/op 73.59
Benchmark_Redirect_processFlashMessages - ns/op 228.8 ns/op 3.109 ns/op 73.59
Benchmark_Redirect_processFlashMessages - B/op 112 B/op 0 B/op +∞
Benchmark_Redirect_processFlashMessages - allocs/op 1 allocs/op 0 allocs/op +∞

This comment was automatically generated by workflow using github-action-benchmark.

Copy link
Contributor

@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: 14

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9655c30 and 2a73d5a.

Files selected for processing (4)
  • ctx.go (2 hunks)
  • redirect.go (7 hunks)
  • redirect_msgp.go (1 hunks)
  • redirect_test.go (19 hunks)
Files skipped from review as they are similar to previous changes (2)
  • ctx.go
  • redirect_test.go
Additional context used
GitHub Check: codecov/patch
redirect_msgp.go

[warning] 10-17: redirect_msgp.go#L10-L17
Added lines #L10 - L17 were not covered by tests


[warning] 19-24: redirect_msgp.go#L19-L24
Added lines #L19 - L24 were not covered by tests


[warning] 26-31: redirect_msgp.go#L26-L31
Added lines #L26 - L31 were not covered by tests


[warning] 33-37: redirect_msgp.go#L33-L37
Added lines #L33 - L37 were not covered by tests


[warning] 39-43: redirect_msgp.go#L39-L43
Added lines #L39 - L43 were not covered by tests


[warning] 45-49: redirect_msgp.go#L45-L49
Added lines #L45 - L49 were not covered by tests


[warning] 51-55: redirect_msgp.go#L51-L55
Added lines #L51 - L55 were not covered by tests


[warning] 59-59: redirect_msgp.go#L59
Added line #L59 was not covered by tests


[warning] 63-63: redirect_msgp.go#L63
Added line #L63 was not covered by tests


[warning] 66-68: redirect_msgp.go#L66-L68
Added lines #L66 - L68 were not covered by tests


[warning] 70-73: redirect_msgp.go#L70-L73
Added lines #L70 - L73 were not covered by tests


[warning] 76-78: redirect_msgp.go#L76-L78
Added lines #L76 - L78 were not covered by tests


[warning] 80-83: redirect_msgp.go#L80-L83
Added lines #L80 - L83 were not covered by tests


[warning] 86-88: redirect_msgp.go#L86-L88
Added lines #L86 - L88 were not covered by tests


[warning] 90-93: redirect_msgp.go#L90-L93
Added lines #L90 - L93 were not covered by tests


[warning] 96-98: redirect_msgp.go#L96-L98
Added lines #L96 - L98 were not covered by tests


[warning] 100-103: redirect_msgp.go#L100-L103
Added lines #L100 - L103 were not covered by tests


[warning] 105-105: redirect_msgp.go#L105
Added line #L105 was not covered by tests


[warning] 134-135: redirect_msgp.go#L134-L135
Added lines #L134 - L135 were not covered by tests


[warning] 141-142: redirect_msgp.go#L141-L142
Added lines #L141 - L142 were not covered by tests


[warning] 148-149: redirect_msgp.go#L148-L149
Added lines #L148 - L149 were not covered by tests


[warning] 154-155: redirect_msgp.go#L154-L155
Added lines #L154 - L155 were not covered by tests

redirect.go

[warning] 122-123: redirect.go#L122-L123
Added lines #L122 - L123 were not covered by tests


[warning] 125-125: redirect.go#L125
Added line #L125 was not covered by tests


[warning] 150-150: redirect.go#L150
Added line #L150 was not covered by tests


[warning] 152-152: redirect.go#L152
Added line #L152 was not covered by tests


[warning] 200-200: redirect.go#L200
Added line #L200 was not covered by tests


[warning] 232-232: redirect.go#L232
Added line #L232 was not covered by tests


[warning] 305-305: redirect.go#L305
Added line #L305 was not covered by tests


[warning] 318-318: redirect.go#L318
Added line #L318 was not covered by tests

Additional comments not posted (4)
redirect_msgp.go (1)

181-185: LGTM!

The Msgsize method correctly calculates the size of a serialized redirectionMsg.

redirect.go (3)

Line range hint 235-243: LGTM!

The To method correctly handles redirection and processes flash messages.

Tools
GitHub Check: codecov/patch

[warning] 150-150: redirect.go#L150
Added line #L150 was not covered by tests


[warning] 152-152: redirect.go#L152
Added line #L152 was not covered by tests


[warning] 200-200: redirect.go#L200
Added line #L200 was not covered by tests


[warning] 232-232: redirect.go#L232
Added line #L232 was not covered by tests


Line range hint 246-273: LGTM!

The Route method correctly handles redirection to named routes with parameters and queries.


Line range hint 276-292: LGTM!

The Back method correctly handles redirection to the referer or fallback URL.

redirect_msgp.go Show resolved Hide resolved
redirect_msgp.go Show resolved Hide resolved
redirect_msgp.go Show resolved Hide resolved
redirect_msgp.go Show resolved Hide resolved
redirect_msgp.go Show resolved Hide resolved
redirect.go Show resolved Hide resolved
redirect.go Show resolved Hide resolved
redirect.go Show resolved Hide resolved
redirect.go Show resolved Hide resolved
redirect.go Show resolved Hide resolved
@ReneWerner87
Copy link
Member

@efectn can i merge , or should i wait for the coverage extension ?
image

ctx.go Show resolved Hide resolved
@efectn
Copy link
Member Author

efectn commented Aug 21, 2024

@efectn can i merge , or should i wait for the coverage extension ? image

I will complete it tomorrow

@gaby
Copy link
Member

gaby commented Aug 22, 2024

@efectn If you can add the command for generating the msgp to the Makefile.

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2a73d5a and d73ff5a.

Files selected for processing (2)
  • redirect.go (7 hunks)
  • redirect_msgp_test.go (1 hunks)
Additional context used
GitHub Check: codecov/patch
redirect.go

[warning] 122-123: redirect.go#L122-L123
Added lines #L122 - L123 were not covered by tests


[warning] 125-125: redirect.go#L125
Added line #L125 was not covered by tests


[warning] 150-150: redirect.go#L150
Added line #L150 was not covered by tests


[warning] 152-152: redirect.go#L152
Added line #L152 was not covered by tests


[warning] 200-200: redirect.go#L200
Added line #L200 was not covered by tests


[warning] 232-232: redirect.go#L232
Added line #L232 was not covered by tests


[warning] 305-305: redirect.go#L305
Added line #L305 was not covered by tests


[warning] 318-318: redirect.go#L318
Added line #L318 was not covered by tests

Additional comments not posted (16)
redirect_msgp_test.go (8)

12-33: LGTM! Comprehensive marshaling and unmarshaling test.

The test for redirectionMsg correctly checks for errors and leftover bytes after unmarshaling and skipping.


35-42: LGTM! Well-structured benchmark for marshaling.

The benchmark for redirectionMsg marshaling is straightforward and reports allocations.


44-54: LGTM! Well-structured benchmark for appending marshaled messages.

The benchmark for appending marshaled redirectionMsg is well-structured and reports allocations.


56-68: LGTM! Well-structured benchmark for unmarshaling.

The benchmark for redirectionMsg unmarshaling is straightforward and reports allocations.


70-92: LGTM! Comprehensive encoding and decoding test.

The test for redirectionMsg correctly checks for errors and message size accuracy.


94-106: LGTM! Well-structured benchmark for encoding.

The benchmark for redirectionMsg encoding is straightforward and reports allocations.


108-123: LGTM! Well-structured benchmark for decoding.

The benchmark for redirectionMsg decoding is straightforward and reports allocations.


125-146: LGTM! Comprehensive marshaling and unmarshaling test for multiple messages.

The test for redirectionMsgs correctly checks for errors and leftover bytes after unmarshaling and skipping.

redirect.go (8)

38-45: LGTM! Well-defined structures for message handling.

The redirectionMsg and redirectionMsgs structures are well-defined and encapsulate the necessary data for flash messages and old input data.


47-58: LGTM! Well-defined structures for input and message data.

The OldInputData and FlashMessage structures are well-defined and encapsulate the necessary data for old input data and flash messages.


112-133: LGTM! Improved message management in With method.

The With method is well-structured and improves message management by preventing duplicates and allowing updates.

Tools
GitHub Check: codecov/patch

[warning] 122-123: redirect.go#L122-L123
Added lines #L122 - L123 were not covered by tests


[warning] 125-125: redirect.go#L125
Added line #L125 was not covered by tests


147-163: LGTM! Effective handling of input data in WithInput method.

The WithInput method is well-structured and handles different content types effectively.

Tools
GitHub Check: codecov/patch

[warning] 150-150: redirect.go#L150
Added line #L150 was not covered by tests


[warning] 152-152: redirect.go#L152
Added line #L152 was not covered by tests


170-179: LGTM! Clear representation of flash messages in Messages method.

The Messages method is well-structured and provides a clear representation of flash messages.


187-200: LGTM! Effective retrieval of specific flash messages in Message method.

The Message method is well-structured and effectively retrieves specific flash messages.

Tools
GitHub Check: codecov/patch

[warning] 200-200: redirect.go#L200
Added line #L200 was not covered by tests


204-216: LGTM! Clear representation of old input data in OldInputs method.

The OldInputs method is well-structured and provides a clear representation of old input data.


220-232: LGTM! Effective retrieval of specific old input data in OldInput method.

The OldInput method is well-structured and effectively retrieves specific old input data.

Tools
GitHub Check: codecov/patch

[warning] 232-232: redirect.go#L232
Added line #L232 was not covered by tests

Comment on lines +312 to +325
if len(r.messages) == 0 {
return
}
}

// parseMessage is a helper function to parse flash messages and old input data
func parseMessage(raw string) (string, string) { //nolint: revive // not necessary
if i := findNextNonEscapedCharsetPosition(raw, []byte(CookieDataAssigner)); i != -1 {
return RemoveEscapeChar(raw[:i]), RemoveEscapeChar(raw[i+1:])
val, err := r.messages.MarshalMsg(nil)
if err != nil {
return
}

return RemoveEscapeChar(raw), ""
r.c.Cookie(&Cookie{
Name: FlashCookieName,
Value: r.c.app.getString(val),
SessionOnly: true,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Add error handling to processFlashMessages method.

The method lacks error handling for the marshaling process. Consider adding error handling to ensure robustness.

Apply this diff to add error handling:

316,318c316,320
< 	val, err := r.messages.MarshalMsg(nil)
< 	if err != nil {
< 		return
---
> 	if val, err := r.messages.MarshalMsg(nil); err != nil {
> 		// Handle error appropriately
> 		r.c.app.LogError("Failed to marshal flash messages", err)
> 		return
> 	}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if len(r.messages) == 0 {
return
}
}
// parseMessage is a helper function to parse flash messages and old input data
func parseMessage(raw string) (string, string) { //nolint: revive // not necessary
if i := findNextNonEscapedCharsetPosition(raw, []byte(CookieDataAssigner)); i != -1 {
return RemoveEscapeChar(raw[:i]), RemoveEscapeChar(raw[i+1:])
val, err := r.messages.MarshalMsg(nil)
if err != nil {
return
}
return RemoveEscapeChar(raw), ""
r.c.Cookie(&Cookie{
Name: FlashCookieName,
Value: r.c.app.getString(val),
SessionOnly: true,
})
if len(r.messages) == 0 {
return
}
if val, err := r.messages.MarshalMsg(nil); err != nil {
// Handle error appropriately
r.c.app.LogError("Failed to marshal flash messages", err)
return
}
r.c.Cookie(&Cookie{
Name: FlashCookieName,
Value: r.c.app.getString(val),
SessionOnly: true,
})
Tools
GitHub Check: codecov/patch

[warning] 318-318: redirect.go#L318
Added line #L318 was not covered by tests

Comment on lines +298 to +305
// parseAndClearFlashMessages is a method to get flash messages before they are getting removed
func (r *Redirect) parseAndClearFlashMessages() {
// parse flash messages
cookieValue := r.c.Cookies(FlashCookieName)

var commaPos int
for {
commaPos = findNextNonEscapedCharsetPosition(cookieValue, []byte(CookieDataSeparator))
if commaPos == -1 {
r.c.redirectionMessages = append(r.c.redirectionMessages, utils.Trim(cookieValue, ' '))
break
}
r.c.redirectionMessages = append(r.c.redirectionMessages, utils.Trim(cookieValue[:commaPos], ' '))
cookieValue = cookieValue[commaPos+1:]
_, err := r.c.flashMessages.UnmarshalMsg(r.c.app.getBytes(cookieValue))
if err != nil {
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Add error handling to parseAndClearFlashMessages method.

The method lacks error handling for the unmarshaling process. Consider adding error handling to ensure robustness.

Apply this diff to add error handling:

303,305c303,307
< 	_, err := r.c.flashMessages.UnmarshalMsg(r.c.app.getBytes(cookieValue))
< 	if err != nil {
< 		return
---
> 	if _, err := r.c.flashMessages.UnmarshalMsg(r.c.app.getBytes(cookieValue)); err != nil {
> 		// Handle error appropriately
> 		r.c.app.LogError("Failed to parse flash messages", err)
> 		return
> 	}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// parseAndClearFlashMessages is a method to get flash messages before they are getting removed
func (r *Redirect) parseAndClearFlashMessages() {
// parse flash messages
cookieValue := r.c.Cookies(FlashCookieName)
var commaPos int
for {
commaPos = findNextNonEscapedCharsetPosition(cookieValue, []byte(CookieDataSeparator))
if commaPos == -1 {
r.c.redirectionMessages = append(r.c.redirectionMessages, utils.Trim(cookieValue, ' '))
break
}
r.c.redirectionMessages = append(r.c.redirectionMessages, utils.Trim(cookieValue[:commaPos], ' '))
cookieValue = cookieValue[commaPos+1:]
_, err := r.c.flashMessages.UnmarshalMsg(r.c.app.getBytes(cookieValue))
if err != nil {
return
// parseAndClearFlashMessages is a method to get flash messages before they are getting removed
func (r *Redirect) parseAndClearFlashMessages() {
// parse flash messages
cookieValue := r.c.Cookies(FlashCookieName)
if _, err := r.c.flashMessages.UnmarshalMsg(r.c.app.getBytes(cookieValue)); err != nil {
// Handle error appropriately
r.c.app.LogError("Failed to parse flash messages", err)
return
}
Tools
GitHub Check: codecov/patch

[warning] 305-305: redirect.go#L305
Added line #L305 was not covered by tests

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d73ff5a and 5956dde.

Files selected for processing (1)
  • redirect_test.go (19 hunks)
Additional comments not posted (12)
redirect_test.go (12)

38-51: LGTM! Test for redirection with flash messages is well-implemented.

The test correctly verifies the status code and the presence of flash messages.


186-194: LGTM! Test for redirection back with flash messages is well-implemented.

The test correctly verifies the status code and the presence of flash messages.


229-245: LGTM! Test for redirection route with flash messages is well-implemented.

The test correctly verifies the status code and the presence of flash messages.


261-281: LGTM! Test for redirection route with old input data is well-implemented.

The test correctly verifies the status code and the presence of old input data.


295-367: LGTM! Test for parsing and clearing flash messages is well-implemented.

The test correctly verifies the correctness of flash messages and old input data.


451-459: LGTM! Benchmark for redirection with flash messages is well-implemented.

The benchmark correctly measures the performance of redirection with flash messages.


Line range hint 491-521: LGTM! Benchmark for parsing and clearing flash messages is well-implemented.

The benchmark correctly measures the performance of parsing and clearing flash messages.


542-550: LGTM! Benchmark for processing flash messages is well-implemented.

The benchmark correctly measures the performance of processing flash messages.


Line range hint 562-587: LGTM! Benchmark for retrieving flash messages is well-implemented.

The benchmark correctly measures the performance of retrieving flash messages.


Line range hint 599-622: LGTM! Benchmark for retrieving old input data is well-implemented.

The benchmark correctly measures the performance of retrieving old input data.


Line range hint 634-653: LGTM! Benchmark for retrieving a specific flash message is well-implemented.

The benchmark correctly measures the performance of retrieving a specific flash message.


Line range hint 665-683: LGTM! Benchmark for retrieving a specific old input data is well-implemented.

The benchmark correctly measures the performance of retrieving a specific old input data.

Copy link
Contributor

@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: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5956dde and bbe74e8.

Files selected for processing (1)
  • redirect_test.go (18 hunks)
Additional context used
golangci-lint
redirect_test.go

251-251: Test_Redirect_Route_WithOldInput's subtests should call t.Parallel

(tparallel)

GitHub Check: lint
redirect_test.go

[failure] 251-251:
Test_Redirect_Route_WithOldInput's subtests should call t.Parallel (tparallel)

Additional comments not posted (10)
redirect_test.go (10)

40-53: Ensure correct handling of flash messages in Test_Redirect_To_WithFlashMessages.

The test case now includes flash messages with varying levels. Ensure that the With method correctly handles the new parameter.

Verify that the With method implementation correctly processes the additional parameter for flash messages.


188-196: Ensure flash messages are correctly parsed in Test_Redirect_Back_WithFlashMessages.

The test checks for the presence of flash messages after redirection. Ensure that the parsing logic is correct.

Verify that the UnmarshalMsg method correctly parses the flash messages from cookies.


231-247: Ensure flash messages are correctly handled in Test_Redirect_Route_WithFlashMessages.

The test verifies flash messages in the redirect context. Ensure that the With method and message handling logic are correct.

Verify that the With method and message handling logic correctly manage flash messages in the redirect context.


375-451: Ensure correct parsing and clearing of flash messages in Test_Redirect_parseAndClearFlashMessages.

The test verifies the parsing and clearing of flash messages. Ensure that the parseAndClearFlashMessages method is correctly implemented.

Verify that the parseAndClearFlashMessages method correctly processes and clears flash messages.


535-543: Ensure flash messages are correctly handled in Benchmark_Redirect_Route_WithFlashMessages.

The benchmark tests the performance of handling flash messages. Ensure that the With method and message handling logic are efficient.

Verify that the With method and message handling logic are optimized for performance.


626-634: Ensure flash messages are correctly processed in Benchmark_Redirect_processFlashMessages.

The benchmark tests the performance of processing flash messages. Ensure that the processFlashMessages method is efficient.

Verify that the processFlashMessages method is optimized for performance.


Line range hint 646-671: Ensure flash messages are correctly retrieved in Benchmark_Redirect_Messages.

The benchmark tests the retrieval of flash messages. Ensure that the Messages method is efficient.

Verify that the Messages method is optimized for performance.


Line range hint 683-706: Ensure old input data is correctly retrieved in Benchmark_Redirect_OldInputs.

The benchmark tests the retrieval of old input data. Ensure that the OldInputs method is efficient.

Verify that the OldInputs method is optimized for performance.


Line range hint 718-737: Ensure flash message retrieval is efficient in Benchmark_Redirect_Message.

The benchmark tests the retrieval of a specific flash message. Ensure that the Message method is efficient.

Verify that the Message method is optimized for performance.


Line range hint 749-767: Ensure old input retrieval is efficient in Benchmark_Redirect_OldInput.

The benchmark tests the retrieval of a specific old input. Ensure that the OldInput method is efficient.

Verify that the OldInput method is optimized for performance.

redirect_test.go Outdated Show resolved Hide resolved
redirect_test.go Outdated Show resolved Hide resolved
redirect_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bbe74e8 and 3adc842.

Files selected for processing (1)
  • redirect_test.go (18 hunks)
Files skipped from review as they are similar to previous changes (1)
  • redirect_test.go

@ReneWerner87
Copy link
Member

@efectn If you can add the command for generating the msgp to the Makefile.

you mean this
https://github.com/gofiber/fiber/blob/main/Makefile#L61-L67

@efectn
Copy link
Member Author

efectn commented Aug 29, 2024

@efectn If you can add the command for generating the msgp to the Makefile.

you mean this main/Makefile#L61-L67

done

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3adc842 and bff1f6c.

Files selected for processing (1)
  • Makefile (1 hunks)
Additional comments not posted (1)
Makefile (1)

68-68: Add a brief comment explaining the purpose of the new command.

To improve maintainability, add a brief comment explaining the purpose of the new command for generating a message pack file from redirect.go.

+## msgp: ⚡️ Generate msgp for redirect.go
.PHONY: msgp
msgp:
	go run github.com/tinylib/msgp@latest -file="middleware/cache/manager.go" -o="middleware/cache/manager_msgp.go" -tests=true -unexported
	go run github.com/tinylib/msgp@latest -file="middleware/session/data.go" -o="middleware/session/data_msgp.go" -tests=true -unexported
	go run github.com/tinylib/msgp@latest -file="middleware/csrf/storage_manager.go" -o="middleware/csrf/storage_manager_msgp.go" -tests=true -unexported
	go run github.com/tinylib/msgp@latest -file="middleware/limiter/manager.go" -o="middleware/limiter/manager_msgp.go" -tests=true -unexported
	go run github.com/tinylib/msgp@latest -file="middleware/idempotency/response.go" -o="middleware/idempotency/response_msgp.go" -tests=true -unexported
	go run github.com/tinylib/msgp@latest -file="redirect.go" -o="redirect_msgp.go" -tests=true -unexported

@gaby
Copy link
Member

gaby commented Aug 29, 2024

@efectn If you can add the command for generating the msgp to the Makefile.

you mean this https://github.com/gofiber/fiber/blob/main/Makefile#L61-L67

Yes

@ReneWerner87
Copy link
Member

@efectn If you can add the command for generating the msgp to the Makefile.

you mean this main/Makefile#L61-L67

done

i changed it a bit
f6cf451

normally go generate is ok, but the existing magic comments were wrong -> fixed

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bff1f6c and da8473c.

Files selected for processing (7)
  • Makefile (1 hunks)
  • ctx_interface_gen.go (1 hunks)
  • middleware/cache/manager.go (1 hunks)
  • middleware/csrf/storage_manager.go (1 hunks)
  • middleware/idempotency/response.go (1 hunks)
  • middleware/limiter/manager.go (1 hunks)
  • middleware/session/data.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • middleware/limiter/manager.go
Files skipped from review as they are similar to previous changes (1)
  • Makefile
Additional comments not posted (5)
middleware/idempotency/response.go (1)

6-6: Verify the impact of enabling I/O operations.

Removing the -io=false flag will enable I/O operations in the generated code. Verify if this change impacts the performance or functionality of the response struct.

Run the following script to check for any performance or functionality issues:

middleware/session/data.go (1)

9-9: LGTM!

The additional parameters in the go:generate directive improve the clarity and control over the output of the msgp tool.

The code changes are approved.

middleware/csrf/storage_manager.go (1)

14-14: LGTM!

The additional parameters in the go:generate directive improve the clarity and control over the output of the msgp tool.

The code changes are approved.

middleware/cache/manager.go (1)

13-13: LGTM!

The updated go:generate directive enhances the functionality of the code generation process by specifying the output file, enabling test generation, and including unexported fields in the serialization process.

ctx_interface_gen.go (1)

333-333: LGTM!

The addition of the getBody() method enhances the Ctx interface's functionality by allowing implementations to include logic for retrieving the body data.

@ReneWerner87 ReneWerner87 merged commit 08d9fda into main Aug 29, 2024
14 of 16 checks passed
@efectn efectn deleted the redirect-msgp-v3 branch September 1, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants