-
Notifications
You must be signed in to change notification settings - Fork 175
[ISSUE #4087]♻️Clean up remaining clippy warnings #4107
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,15 +53,15 @@ mod tests { | |
| let data = r#"{"topic":"test_topic"}"#; | ||
| let header: GetTopicStatsInfoRequestHeader = serde_json::from_str(data).unwrap(); | ||
| assert_eq!(header.topic, CheetahString::from_static_str("test_topic")); | ||
| assert!(!header.topic_request_header.is_none()); | ||
| assert!(header.topic_request_header.is_some()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainSerde flatten Option: asserting Some here is likely wrong. JSON only contains Apply: - assert!(header.topic_request_header.is_some());
+ assert!(header.topic_request_header.is_none());Run to verify the struct shape/attrs: Also applies to: 64-64 🏁 Script executed: #!/bin/bash
rg -n -C3 $'struct\\s+TopicRequestHeader\\b' -g '!**/target/**'
rg -n -C2 '#\\[serde\\(default\\)' -g '!**/target/**' rocketmq-remoting/srcLength of output: 235 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "PWD: $(pwd)"
echo "Top-level files:"
ls -la | sed -n '1,120p' || true
echo; echo "Searching for struct definitions and usages of TopicRequestHeader..."
rg -n --hidden --follow --no-messages "struct TopicRequestHeader" -S || true
rg -n --hidden --follow --no-messages "TopicRequestHeader" -S || true
echo; echo "Searching for serde attributes (flatten/default) under rocketmq-remoting/src if present..."
rg -n --hidden --follow --no-messages "serde\(" rocketmq-remoting/src -S || true
echo; echo "Printing get_topic_stats_info_request_header.rs (if exists):"
FILE="rocketmq-remoting/src/protocol/header/get_topic_stats_info_request_header.rs"
if [ -f "$FILE" ]; then
sed -n '1,240p' "$FILE"
else
echo "file not found: $FILE"
fiLength of output: 62624 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "----- namesrv/topic_operation_header.rs -----"
sed -n '1,240p' rocketmq-remoting/src/protocol/header/namesrv/topic_operation_header.rs || true
echo; echo "----- rpc/topic_request_header.rs -----"
sed -n '1,240p' rocketmq-remoting/src/rpc/topic_request_header.rs || trueLength of output: 7844 Expect None for flattened optional TopicRequestHeader in tests TopicRequestHeader (namesrv) has only optional fields (lo, rpc); #[serde(flatten)] Option will be None when the JSON contains only "topic" — update the test assertions to expect None. File: rocketmq-remoting/src/protocol/header/get_topic_stats_info_request_header.rs — apply: - assert!(header.topic_request_header.is_some());
+ assert!(header.topic_request_header.is_none());Also update the duplicate assertion in the other test (~line 64). 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| #[test] | ||
| fn get_topic_stats_info_request_header_handles_missing_optional_fields() { | ||
| let data = r#"{"topic":"test_topic"}"#; | ||
| let header: GetTopicStatsInfoRequestHeader = serde_json::from_str(data).unwrap(); | ||
| assert_eq!(header.topic, CheetahString::from_static_str("test_topic")); | ||
| assert!(!header.topic_request_header.is_none()); | ||
| assert!(header.topic_request_header.is_some()); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,7 +58,7 @@ mod tests { | |||||
| let header: QuerySubscriptionByConsumerRequestHeader = serde_json::from_str(data).unwrap(); | ||||||
| assert_eq!(header.group, CheetahString::from_static_str("test_group")); | ||||||
| assert_eq!(header.topic, CheetahString::from_static_str("test_topic")); | ||||||
| assert!(!header.topic_request_header.is_none()); | ||||||
| assert!(header.topic_request_header.is_some()); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainSerde Option expectation inverted (should be None). Deserializing Apply: - assert!(header.topic_request_header.is_some());
+ assert!(header.topic_request_header.is_none());Sanity-check the header type: Also applies to: 70-70 🏁 Script executed: #!/bin/bash
rg -n -C3 $'struct\\s+TopicRequestHeader\\b' -g '!**/target/**'Length of output: 148 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "PWD: $(pwd)"
echo "---- Inspect file if present ----"
FILE="rocketmq-remoting/src/protocol/header/query_subscription_by_consumer_request_header.rs"
if [ -f "$FILE" ]; then
nl -ba -w3 -s": " "$FILE" | sed -n '1,200p'
else
echo "FILE NOT FOUND: $FILE"
fi
echo "---- rg search: TopicRequestHeader ----"
rg -n --hidden -uu -S 'TopicRequestHeader' || true
echo "---- rg search: struct TopicRequestHeader ----"
rg -n --hidden -uu -P 'struct\s+TopicRequestHeader\b' || true
echo "---- rg search: topic_request_header occurrences ----"
rg -n --hidden -uu -S 'topic_request_header' || trueLength of output: 98 🏁 Script executed: #!/bin/bash
echo "PWD: $(pwd)"
FILE="rocketmq-remoting/src/protocol/header/query_subscription_by_consumer_request_header.rs"
echo "---- Inspect file if present ----"
if [ -f "$FILE" ]; then
echo "FILE FOUND: $FILE"
echo "----- lines 1-200 -----"
sed -n '1,200p' "$FILE" || true
echo "----- lines 50-80 -----"
sed -n '50,80p' "$FILE" || true
else
echo "FILE NOT FOUND: $FILE"
fi
echo "---- ripgrep search (prefer) ----"
if command -v rg >/dev/null 2>&1; then
rg -n --hidden -uu -S 'TopicRequestHeader' -g '!**/target/**' || true
rg -n --hidden -uu -P 'struct\s+TopicRequestHeader\b' -g '!**/target/**' || true
rg -n --hidden -uu -S 'topic_request_header' -g '!**/target/**' || true
rg -n --hidden -uu -S 'TopicRequest' -g '!**/target/**' || true
else
echo "rg not available; falling back to grep"
grep -RIn --exclude-dir=target -E 'TopicRequestHeader|topic_request_header|TopicRequest' . || true
fi
echo "---- show workspace Cargo.toml if present ----"
if [ -f Cargo.toml ]; then
sed -n '1,200p' Cargo.toml || true
else
echo "No Cargo.toml at repo root"
fiLength of output: 8268 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "PWD: $(pwd)"
echo
echo "---- list rpc dir ----"
ls -la rocketmq-remoting/src/rpc || true
echo
echo "---- list protocol/header dir ----"
ls -la rocketmq-remoting/src/protocol/header || true
echo
echo "---- grep for TopicRequestHeader across crate ----"
grep -RIn --exclude-dir=target --exclude-dir=.git 'TopicRequestHeader' rocketmq-remoting || true
echo
echo "---- show candidate files ----"
for f in \
rocketmq-remoting/src/rpc/topic_request_header.rs \
rocketmq-remoting/src/protocol/header/topic_request_header.rs \
rocketmq-remoting/src/protocol/topic_request_header.rs \
rocketmq-remoting/src/rpc/mod.rs; do
if [ -f "$f" ]; then
echo
echo "------ $f ------"
sed -n '1,240p' "$f"
else
echo
echo "MISSING: $f"
fi
doneLength of output: 30392 Expect flattened Option to be None — fix tests. Flattening an Option yields None when no nested fields are present; the tests currently assert Some. Update the two test assertions in rocketmq-remoting/src/protocol/header/query_subscription_by_consumer_request_header.rs (deserializes_correctly and handles_missing_optional_fields). Apply: - assert!(header.topic_request_header.is_some());
+ assert!(header.topic_request_header.is_none());📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| } | ||||||
|
|
||||||
| #[test] | ||||||
|
|
@@ -67,7 +67,7 @@ mod tests { | |||||
| let header: QuerySubscriptionByConsumerRequestHeader = serde_json::from_str(data).unwrap(); | ||||||
| assert_eq!(header.group, CheetahString::from_static_str("test_group")); | ||||||
| assert_eq!(header.topic, CheetahString::from_static_str("test_topic")); | ||||||
| assert!(!header.topic_request_header.is_none()); | ||||||
| assert!(header.topic_request_header.is_some()); | ||||||
| } | ||||||
|
|
||||||
| #[test] | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -271,7 +271,7 @@ mod tests { | |||||||||||||||||||
|
|
||||||||||||||||||||
| broker_data.remove_broker_by_addr(1, &"127.0.0.1".into()); | ||||||||||||||||||||
| //assert!(broker_data.broker_addrs.get(&1).is_none()); | ||||||||||||||||||||
| assert!(broker_data.broker_addrs.get(&2).is_some()); | ||||||||||||||||||||
| assert!(broker_data.broker_addrs.contains_key(&2)); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
272
to
275
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-enable the assertion that verifies removal (prevent regression hiding). The commented assertion is the one that would catch the bug above. Keep the new Apply: - broker_data.remove_broker_by_addr(1, &"127.0.0.1".into());
- //assert!(broker_data.broker_addrs.get(&1).is_none());
- assert!(broker_data.broker_addrs.contains_key(&2));
+ broker_data.remove_broker_by_addr(1, &"127.0.0.1".into());
+ assert!(broker_data.broker_addrs.get(&1).is_none());
+ assert!(broker_data.broker_addrs.contains_key(&2));📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| #[test] | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vector initialization
vec![EpochEntry]is invalid syntax. It should bevec![EpochEntry::default()]or an equivalent valid constructor call.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default_constructed_unit_structs adds code complexity and an unnecessary function call