Skip to content

[ISSUE #4087]♻️Clean up existing clippy warnings of useless_vec, redundant_field_names, let_unit_value, manual_range_contains#4106

Merged
rocketmq-rust-bot merged 1 commit intomxsm:mainfrom
WaterWhisperer:refactor-issueNo4087
Sep 23, 2025
Merged

[ISSUE #4087]♻️Clean up existing clippy warnings of useless_vec, redundant_field_names, let_unit_value, manual_range_contains#4106
rocketmq-rust-bot merged 1 commit intomxsm:mainfrom
WaterWhisperer:refactor-issueNo4087

Conversation

@WaterWhisperer
Copy link
Contributor

@WaterWhisperer WaterWhisperer commented Sep 23, 2025

Which Issue(s) This PR Fixes(Closes)

#4087 Not complete yet

Brief Description

Clean up existing clippy warnings of types:

  • useless_vec
  • redundant_field_names
  • let_unit_value
  • manual_range_contains

How Did You Test This Change?

Summary by CodeRabbit

  • New Features
    • No user-facing changes in this release.
  • Tests
    • Updated tests to use slice literals where appropriate and to await timing controls for more stable async behavior.
    • Adjusted assertion styles to use explicit range containment checks.
    • Added serialization parity checks and tightened construction semantics in tests for more robust equality verification.
  • Style
    • Simplified test initialization via shorthand and minor naming cleanups.

Copilot AI review requested due to automatic review settings September 23, 2025 00:57
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

Warning

Rate limit exceeded

@WaterWhisperer has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 55 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b20f4af and c3e8ee4.

📒 Files selected for processing (3)
  • rocketmq-remoting/src/protocol/body/cluster_acl_version_info.rs (2 hunks)
  • rocketmq-remoting/src/protocol/header/extra_info_util.rs (21 hunks)
  • rocketmq/src/schedule.rs (3 hunks)

Walkthrough

Small, test-only changes: adjusted variable moves/clones and added a JSON equality check; replaced Vec arguments with slice literals in tests; shortened and awaited a sleep in scheduler tests and switched assertions to range containment. No production code or public APIs changed.

Changes

Cohort / File(s) Summary of Changes
Protocol tests: cluster ACL version
rocketmq-remoting/src/protocol/body/cluster_acl_version_info.rs
Updated test variable names and ownership (use of moved vs cloned all_acl_config_data_version), added JSON-serialization equality assertion; serialization test moves value instead of cloning.
Protocol tests: slice-based args
rocketmq-remoting/src/protocol/header/extra_info_util.rs
Replaced Vec/&Vec arguments with slice literals (&[...]/&[T]) across many test calls to match functions that accept slices; no signature changes.
Scheduler tests: timing & assertions
rocketmq/src/schedule.rs
In tests, changed an un-awaited sleep to an awaited one and reduced delay (1s → 400ms) before task cancellation; assertions refactored to use (a..=b).contains(&x) pattern.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibble tests with twitching nose,
Slices leap where Vecs once chose.
Moves and clones, a tidy spin,
Timers trimmed — the checks hop in. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately describes the primary intent of the changeset: cleaning up Clippy warnings for the listed lints and references the related issue number, which aligns with the PR objectives and the file-level changes. It is specific, actionable, and meaningful to a reviewer scanning history.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

@rocketmq-rust-robot rocketmq-rust-robot added the refactor♻️ refactor code label Sep 23, 2025
@rocketmq-rust-bot
Copy link
Collaborator

🔊@WaterWhisperer 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR cleans up clippy warnings in the Rust codebase by addressing four specific lint categories: useless_vec, redundant_field_names, let_unit_value, and manual_range_contains.

  • Replaced vec![] with slice references (&[]) in test functions where vector ownership isn't needed
  • Removed redundant field names in struct initialization where field and variable names match
  • Fixed unit value assignments by properly awaiting async operations and removing unnecessary assignments
  • Replaced manual range checks with the more idiomatic contains() method on range expressions

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
rocketmq/src/schedule.rs Fixed unit value assignments and manual range contains checks in tests
rocketmq-remoting/src/protocol/header/extra_info_util.rs Replaced useless vec with slice references in test function calls
rocketmq-remoting/src/protocol/body/cluster_acl_version_info.rs Removed redundant field names in struct initialization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 26.59%. Comparing base (49a9baa) to head (c3e8ee4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4106      +/-   ##
==========================================
+ Coverage   26.55%   26.59%   +0.03%     
==========================================
  Files         575      575              
  Lines       81356    81361       +5     
==========================================
+ Hits        21606    21636      +30     
+ Misses      59750    59725      -25     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rocketmq-remoting/src/protocol/header/extra_info_util.rs (1)

310-316: Builder vs. parser delimiter mismatch (semicolon vs. comma) — potential parse failure

build_msg_offset_info joins offsets with ;, while parse_msg_offset_info expects offsets joined by , and also uses ; to split records. Strings produced by the builder won’t round-trip through the parser and may be split incorrectly.

Apply this diff to emit comma-separated offsets from the builder (keeps ; for record separation used by the parser):

-        for (i, offset) in msg_offsets.iter().enumerate() {
-            string_builder.push_str(&offset.to_string());
-            if i < msg_offsets.len() - 1 {
-                string_builder.push(';');
-            }
-        }
+        for (i, offset) in msg_offsets.iter().enumerate() {
+            if i > 0 {
+                string_builder.push(',');
+            }
+            string_builder.push_str(&offset.to_string());
+        }

And update the corresponding test expectation:

-        assert_eq!(string_builder, "0 7 100;200;300");
+        assert_eq!(string_builder, "0 7 100,200,300");

If this is out of scope for this PR, please file a follow-up and link it to avoid future integration bugs.

Also applies to: 346-352

🧹 Nitpick comments (2)
rocketmq-remoting/src/protocol/body/cluster_acl_version_info.rs (1)

64-83: “equality” test doesn’t assert anything

The test constructs two values but never compares them. Add a concrete assertion to validate equivalence.

Apply this diff to assert via JSON (avoids trait bounds on DataVersion):

     #[test]
     fn cluster_acl_version_info_equality() {
@@
-        let _info1 = ClusterAclVersionInfo {
+        let info1 = ClusterAclVersionInfo {
@@
-        let _info2 = ClusterAclVersionInfo {
+        let info2 = ClusterAclVersionInfo {
@@
-        };
+        };
+
+        assert_eq!(
+            serde_json::to_string(&info1).unwrap(),
+            serde_json::to_string(&info2).unwrap()
+        );
     }
rocketmq/src/schedule.rs (1)

750-752: Awaiting sleep + shorter window improves determinism

Good catch adding .await and trimming the delay; this prevents a no-op sleep and speeds up CI.

For consistency with the rest of the module (which imports tokio::time as time), consider using time::sleep:

-        tokio::time::sleep(Duration::from_millis(400)).await;
+        time::sleep(Duration::from_millis(400)).await;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49a9baa and 1bfd8cc.

📒 Files selected for processing (3)
  • rocketmq-remoting/src/protocol/body/cluster_acl_version_info.rs (2 hunks)
  • rocketmq-remoting/src/protocol/header/extra_info_util.rs (21 hunks)
  • rocketmq/src/schedule.rs (3 hunks)
⏰ 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). (9)
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: build (windows-latest, nightly)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (ubuntu-latest, nightly)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (macos-latest, nightly)
  • GitHub Check: test
  • GitHub Check: build
  • GitHub Check: auto-approve
🔇 Additional comments (5)
rocketmq-remoting/src/protocol/body/cluster_acl_version_info.rs (2)

80-82: Field init shorthand is correct and reduces redundancy.

Using all_acl_config_data_version, here is idiomatic and preserves the intended move semantics.


109-115: Same here: good use of field init shorthand.

No behavior change; the map is moved as intended.

rocketmq/src/schedule.rs (2)

809-812: Replaced manual bounds check with range.contains

This aligns with Clippy’s manual_range_contains guidance and reads better.


838-841: Same improvement here

Cleaner and idiomatic containment check.

rocketmq-remoting/src/protocol/header/extra_info_util.rs (1)

501-927: Tests now pass slices instead of Vec — LGTM

The slice-based calls remove useless_vec overhead and match the function signatures. No functional change.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

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

LGTM

@rocketmq-rust-bot
Copy link
Collaborator

🔊@WaterWhisperer 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

@rocketmq-rust-bot
Copy link
Collaborator

🔊@WaterWhisperer 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

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

LGTM

- useless_vec
- redundant_field_names
- let_unit_value
- manual_range_contains
@rocketmq-rust-bot
Copy link
Collaborator

🔊@WaterWhisperer 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

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

LGTM

@rocketmq-rust-bot rocketmq-rust-bot merged commit 86a23c2 into mxsm:main Sep 23, 2025
15 of 17 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed waiting-review waiting review this PR labels Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI review first Ai review pr first approved PR has approved auto merge refactor♻️ refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants