Skip to content

fix(protoc-gen-elixir-grpc): reorder gRPC method#35

Merged
yordis merged 1 commit into
mainfrom
fix-order
Dec 29, 2025
Merged

fix(protoc-gen-elixir-grpc): reorder gRPC method#35
yordis merged 1 commit into
mainfrom
fix-order

Conversation

@yordis

@yordis yordis commented Dec 29, 2025

Copy link
Copy Markdown
Member

No description provided.

@coderabbitai

coderabbitai Bot commented Dec 29, 2025

Copy link
Copy Markdown

Walkthrough

This PR adds alphabetical sorting of service methods within the Elixir gRPC code generator to ensure deterministic output ordering when generating method delegates. Test cases are updated to reflect the new sorted method order.

Changes

Cohort / File(s) Summary
Code Generation Logic
cmd/protoc-gen-elixir-grpc/main.go
Introduces alphabetical sorting of service.Method within generateServiceModule before iterating to generate delegate declarations, ensuring deterministic output order regardless of input method sequence.
Test Cases
cmd/protoc-gen-elixir-grpc/main_test.go
Updates test expectations to reflect alphabetically sorted defdelegate declarations; adds new test case verifying method ordering when input methods are in ascending lexical order (Alpha, Xray, Yankee, Zebra); swaps expected positions of say_hello_stream and say_hello_bidi_stream delegations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through method streams,
Sorting alphabets by moonlight beams,
From Xray down to Alpha's call,
Now every delegate stands tall! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to evaluate relatedness to the changeset. Add a description explaining the purpose and impact of the method reordering changes, even a brief explanation would help reviewers understand the intent.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(protoc-gen-elixir-grpc): reorder gRPC method' clearly summarizes the main change: alphabetical reordering of gRPC methods for deterministic output.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2206a2f and b3fb44e.

📒 Files selected for processing (2)
  • cmd/protoc-gen-elixir-grpc/main.go
  • cmd/protoc-gen-elixir-grpc/main_test.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). (1)
  • GitHub Check: Cursor Bugbot
🔇 Additional comments (3)
cmd/protoc-gen-elixir-grpc/main.go (1)

338-342: LGTM! Sorting ensures deterministic code generation output.

The alphabetical sorting of methods is a good approach to achieve reproducible output. Note that sort.Slice mutates service.Method in place, which is fine here since the descriptor is only used for generation. If this code ever needs to preserve the original order for other purposes, consider sorting a copy instead.

cmd/protoc-gen-elixir-grpc/main_test.go (2)

121-135: LGTM! Expected output correctly updated to reflect alphabetical ordering.

The expected method order now correctly reflects the alphabetical sort: say_hellosay_hello_bidi_streamsay_hello_client_streamsay_hello_stream.


137-222: LGTM! Excellent test coverage for the sorting behavior.

The new test case clearly validates the sorting logic by defining methods in reverse alphabetical order (Zebra, Yankee, Xray, Alpha) and asserting they appear in alphabetical order in the output. This provides strong coverage for the deterministic ordering guarantee.


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.

@cursor

cursor Bot commented Dec 29, 2025

Copy link
Copy Markdown

PR Summary

Ensures deterministic Elixir server code generation by alphabetically sorting gRPC service methods before emitting delegates.

  • Add sort.Slice in generateServiceModule to order service.Method by name
  • Update test expectations for method order and add a test case validating sorting with reverse-ordered methods (main_test.go)

Written by Cursor Bugbot for commit b3fb44e. This will update automatically on new commits. Configure here.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis
yordis marked this pull request as ready for review December 29, 2025 23:10
@yordis
yordis merged commit 29e5c60 into main Dec 29, 2025
4 checks passed
@yordis
yordis deleted the fix-order branch December 29, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant