Skip to content

Commit 3dcd39b

Browse files
committed
chore: clippy
1 parent ef55440 commit 3dcd39b

File tree

5 files changed

+22
-39
lines changed

5 files changed

+22
-39
lines changed

datadog-sidecar-macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
use proc_macro::TokenStream;
55
use quote::{format_ident, quote};
6-
use syn::FnArg::Typed;
76
use syn::__private::Span;
87
use syn::parse::{Parse, ParseStream};
8+
use syn::FnArg::Typed;
99
use syn::{parse_macro_input, parse_quote, Arm, Ident, ItemTrait, Pat, TraitItem};
1010

1111
fn snake_to_camel(ident_str: &str) -> String {

libdd-common-ffi/src/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ mod tests {
181181
let vec = vec![0, 2, 4, 6];
182182
let ffi_vec: Vec<u8> = Vec::from(vec.clone());
183183

184-
for (a, b) in vec.iter().zip(ffi_vec.into_iter()) {
184+
for (a, b) in vec.iter().zip(&ffi_vec) {
185185
assert_eq!(a, b)
186186
}
187187
}

libdd-trace-obfuscation/src/ip_address.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,8 @@ fn parse_ip(s: &str) -> Option<(&str, &str)> {
102102
match ch {
103103
'0'..='9' => continue,
104104
'.' | '-' | '_' => return parse_ip_v4(s, ch),
105-
':' | 'A'..='F' | 'a'..='f' => {
106-
if s.parse::<Ipv6Addr>().is_ok() {
107-
return Some((s, ""));
108-
} else {
109-
return None;
110-
}
105+
':' | 'A'..='F' | 'a'..='f' if s.parse::<Ipv6Addr>().is_ok() => {
106+
return Some((s, ""));
111107
}
112108
'[' => {
113109
// Parse IPv6 in [host]:port format

libdd-trace-obfuscation/src/redis.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,27 @@ fn obfuscate_redis_cmd<'a>(str: &mut String, cmd: &'a str, mut args: Vec<&'a str
3939
let mut uppercase_cmd = [0; 32]; // no redis cmd is longer than 32 chars
4040
let uppercase_cmd = ascii_uppercase(cmd, &mut uppercase_cmd).unwrap_or(&[]);
4141
match uppercase_cmd {
42-
b"AUTH" | b"MIGRATE" | b"HELLO" => {
42+
b"AUTH" | b"MIGRATE" | b"HELLO"
4343
// Obfuscate everything after command:
4444
// • AUTH password
4545
// • MIGRATE host port key|"" destination-db timeout [COPY] [REPLACE] [AUTH password]
4646
// [AUTH2 username password] [KEYS key [key ...]]
4747
// • HELLO [protover [AUTH username password] [SETNAME clientname]]
48-
if !args.is_empty() {
48+
if !args.is_empty() => {
4949
args.clear();
5050
args.push("?");
5151
}
52-
}
53-
b"ACL" => {
52+
b"ACL"
5453
// Obfuscate all arguments after the subcommand:
5554
// • ACL SETUSER username on >password ~keys &channels +commands
5655
// • ACL GETUSER username
5756
// • ACL DELUSER username [username ...]
5857
// • ACL LIST
5958
// • ACL WHOAMI
60-
if args.len() > 1 {
59+
if args.len() > 1 => {
6160
args[1] = "?";
6261
args.drain(2..);
6362
}
64-
}
6563
b"APPEND" | b"GETSET" | b"LPUSHX" | b"GEORADIUSBYMEMBER" | b"RPUSHX" | b"SET"
6664
| b"SETNX" | b"SISMEMBER" | b"ZRANK" | b"ZREVRANK" | b"ZSCORE" => {
6765
// Obfuscate 2nd argument:
@@ -100,7 +98,7 @@ fn obfuscate_redis_cmd<'a>(str: &mut String, cmd: &'a str, mut args: Vec<&'a str
10098
// • LINSERT key BEFORE|AFTER pivot value
10199
args = obfuscate_redis_args_n(args, 3);
102100
}
103-
b"GEOHASH" | b"GEOPOS" | b"GEODIST" | b"LPUSH" | b"RPUSH" | b"SREM" | b"ZREM" | b"SADD" => {
101+
b"GEOHASH" | b"GEOPOS" | b"GEODIST" | b"LPUSH" | b"RPUSH" | b"SREM" | b"ZREM" | b"SADD"
104102
// Obfuscate all arguments after the first one.
105103
// • GEOHASH key member [member ...]
106104
// • GEOPOS key member [member ...]
@@ -110,11 +108,10 @@ fn obfuscate_redis_cmd<'a>(str: &mut String, cmd: &'a str, mut args: Vec<&'a str
110108
// • SREM key member [member ...]
111109
// • ZREM key member [member ...]
112110
// • SADD key member [member ...]
113-
if args.len() > 1 {
111+
if args.len() > 1 => {
114112
args[1] = "?";
115113
args.drain(2..);
116114
}
117-
}
118115
b"GEOADD" => {
119116
// Obfuscating every 3rd argument starting from first
120117
// • GEOADD key longitude latitude member [longitude latitude member ...]

libdd-trace-obfuscation/src/redis_tokenizer.rs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,30 +86,20 @@ impl<'a> RedisTokenizer<'a> {
8686
loop {
8787
match self.curr_char() {
8888
0 => break,
89-
b'\\' => {
90-
if !escape {
91-
escape = true;
92-
self.offset += 1;
93-
continue;
94-
}
95-
}
96-
b'"' => {
97-
if !escape {
98-
quote = !quote
99-
}
89+
b'\\' if !escape => {
90+
escape = true;
91+
self.offset += 1;
92+
continue;
10093
}
101-
b'\n' => {
102-
if !quote {
103-
let span = (start, self.offset);
104-
self.offset += 1;
105-
self.state = RedisTokenType::RedisTokenCommand;
106-
return span;
107-
}
94+
b'"' if !escape => quote = !quote,
95+
b'\n' if !quote => {
96+
let span = (start, self.offset);
97+
self.offset += 1;
98+
self.state = RedisTokenType::RedisTokenCommand;
99+
return span;
108100
}
109-
b' ' => {
110-
if !quote {
111-
return (start, self.offset);
112-
}
101+
b' ' if !quote => {
102+
return (start, self.offset);
113103
}
114104
_ => {}
115105
}

0 commit comments

Comments
 (0)