Skip to content

Commit 03ed485

Browse files
fix: resolve clippy lints across discord-bot crates
- Derive Default for ReactionMode/ReplyToMode with #[default] on variants - Use char array pattern instead of closure in trim_start_matches - Collapse else { if let } into else if let - Suppress too_many_arguments on constructor fns (not worth a builder refactor) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8fd7c50 commit 03ed485

3 files changed

Lines changed: 13 additions & 22 deletions

File tree

rsworkspace/crates/discord-bot/src/bridge.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ impl TypeMapKey for DiscordBridge<MessagePublisher> {
209209

210210
impl DiscordBridge<MessagePublisher> {
211211
/// Create a new bridge backed by a real NATS connection.
212+
#[allow(clippy::too_many_arguments)]
212213
pub fn new(
213214
client: async_nats::Client,
214215
prefix: String,
@@ -243,6 +244,7 @@ impl DiscordBridge<MessagePublisher> {
243244

244245
impl<P: Publish> DiscordBridge<P> {
245246
/// Create a new bridge with any publisher (useful for testing with `MockPublisher`).
247+
#[allow(clippy::too_many_arguments)]
246248
pub fn with_publisher(
247249
publisher: P,
248250
access_config: AccessConfig,

rsworkspace/crates/discord-bot/src/config.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,33 @@ pub struct Config {
1818
}
1919

2020
/// Controls which reaction events are forwarded to NATS.
21-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
21+
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
2222
#[serde(rename_all = "snake_case")]
2323
pub enum ReactionMode {
2424
/// Publish no reaction events
2525
Off,
2626
/// Only publish reactions to messages sent by the bot itself
27+
#[default]
2728
Own,
2829
/// Publish all reaction events (default)
2930
All,
3031
/// Only publish reactions from users in `reaction_allowlist`
3132
Allowlist,
3233
}
3334

34-
impl Default for ReactionMode {
35-
fn default() -> Self {
36-
ReactionMode::Own
37-
}
38-
}
39-
4035
/// Controls when reply references are added to outbound messages.
41-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
36+
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
4237
#[serde(rename_all = "snake_case")]
4338
pub enum ReplyToMode {
4439
/// Never add a reply reference
4540
Off,
4641
/// Add a reply reference only to the first chunk (default)
42+
#[default]
4743
First,
4844
/// Add a reply reference to every chunk
4945
All,
5046
}
5147

52-
impl Default for ReplyToMode {
53-
fn default() -> Self {
54-
ReplyToMode::First
55-
}
56-
}
57-
5848
/// Discord bot specific configuration
5949
#[derive(Debug, Clone, Serialize, Deserialize)]
6050
pub struct DiscordBotConfig {

rsworkspace/crates/discord-bot/src/outbound.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn chunk_text(text: &str, max_len: usize, max_lines: Option<usize>) -> Vec<Strin
132132
bp = boundary; // hard break if no whitespace found
133133
}
134134
chunks.push(remaining[..bp].to_string());
135-
remaining = remaining[bp..].trim_start_matches(|c: char| c == '\n' || c == ' ');
135+
remaining = remaining[bp..].trim_start_matches(['\n', ' ']);
136136
}
137137
}
138138
if chunks.is_empty() {
@@ -424,6 +424,7 @@ impl<N> OutboundProcessor<N>
424424
where
425425
N: trogon_nats::SubscribeClient + trogon_nats::PublishClient + Clone + Send + Sync + 'static,
426426
{
427+
#[allow(clippy::too_many_arguments)]
427428
pub fn new(
428429
http: Arc<Http>,
429430
client: N,
@@ -2996,13 +2997,11 @@ where
29962997
}
29972998
Err(e) => warn!("Failed to parse emoji '{}': {}", emoji_str, e),
29982999
}
2999-
} else {
3000-
if let Err(e) = http.delete_message_reactions(channel, msg).await {
3001-
warn!(
3002-
"Failed to remove all reactions from {}/{}: {}",
3003-
cmd.channel_id, cmd.message_id, e
3004-
);
3005-
}
3000+
} else if let Err(e) = http.delete_message_reactions(channel, msg).await {
3001+
warn!(
3002+
"Failed to remove all reactions from {}/{}: {}",
3003+
cmd.channel_id, cmd.message_id, e
3004+
);
30063005
}
30073006
}
30083007
Err(e) => warn!("Failed to deserialize reaction_remove_all command: {}", e),

0 commit comments

Comments
 (0)