Skip to content

Commit c647690

Browse files
committed
chore: Apply clippy lints from 1.59.0
Signed-off-by: Jesse Szwedko <[email protected]>
1 parent 89aa5f9 commit c647690

File tree

55 files changed

+114
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+114
-100
lines changed

lib/datadog/grok/src/matchers/date.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,12 @@ fn parse_tz_id_or_name(tz: &str) -> Result<FixedOffset, String> {
108108
}
109109

110110
fn parse_offset(tz: &str) -> Result<FixedOffset, String> {
111-
let offset_format;
112111
if tz.len() <= 3 {
113112
// +5, -12
114113
let hours_diff = tz.parse::<i32>().map_err(|e| e.to_string())?;
115114
return Ok(FixedOffset::east(hours_diff * 3600));
116115
}
117-
if tz.contains(':') {
118-
offset_format = "%:z";
119-
} else {
120-
offset_format = "%z";
121-
}
116+
let offset_format = if tz.contains(':') { "%:z" } else { "%z" };
122117
// apparently the easiest way to parse tz offset is parsing the complete datetime
123118
let date_str = format!("2020-04-12 22:10:57 {}", tz);
124119
let datetime =

lib/datadog/search-syntax/src/field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn normalize_fields<T: AsRef<str>>(value: T) -> Vec<Field> {
5959
.collect();
6060
}
6161

62-
let field = match value.replace("@", "custom.") {
62+
let field = match value.replace('@', "custom.") {
6363
v if value.starts_with('@') => Field::Facet(v),
6464
v if DEFAULT_FIELDS.contains(&v.as_ref()) => Field::Default(v),
6565
v if RESERVED_ATTRIBUTES.contains(&v.as_ref()) => Field::Reserved(v),

lib/dnsmsg-parser/src/dns_message_parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ fn parse_character_string(decoder: &mut BinDecoder<'_>) -> DnsParserResult<Strin
10331033
"Unexpected data length: expected {}, got {}. Raw data {}",
10341034
len,
10351035
raw_data.len(),
1036-
format_bytes_as_hex_string(&raw_data.to_vec())
1036+
format_bytes_as_hex_string(raw_data)
10371037
),
10381038
}),
10391039
}
@@ -1106,7 +1106,7 @@ fn parse_domain_name(decoder: &mut BinDecoder<'_>) -> DnsParserResult<Name> {
11061106
}
11071107

11081108
fn escape_string_for_text_representation(original_string: String) -> String {
1109-
original_string.replace("\\", "\\\\").replace("\"", "\\\"")
1109+
original_string.replace('\\', "\\\\").replace('\"', "\\\"")
11101110
}
11111111

11121112
fn parse_unknown_record_type(rtype: u16) -> Option<String> {

lib/file-source/src/fingerprinter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ mod test {
456456
let mut small_files = HashSet::new();
457457
assert!(fingerprinter
458458
.get_fingerprint_or_log_error(
459-
&target_dir.path().to_owned(),
459+
target_dir.path(),
460460
&mut buf,
461461
&mut small_files,
462462
&NoErrors

lib/file-source/src/paths_provider/glob.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ impl<E: FileSourceInternalEvents> Glob<E> {
3535
.collect::<Option<_>>()?;
3636

3737
let exclude_patterns = exclude_patterns
38-
.iter()
39-
.map(|path| path.to_str().map(|path| Pattern::new(path).ok()))
40-
.flatten()
38+
.iter().filter_map(|path| path.to_str().map(|path| Pattern::new(path).ok()))
4139
.collect::<Option<Vec<_>>>()?;
4240

4341
Some(Self {

lib/k8s-e2e-tests/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn get_override_name(namespace: &str, suffix: &str) -> String {
4545

4646
/// Is the MULTINODE environment variable set?
4747
pub fn is_multinode() -> bool {
48-
env::var("MULTINODE".to_string()).is_ok()
48+
env::var("MULTINODE").is_ok()
4949
}
5050

5151
/// Create config adding fullnameOverride entry. This allows multiple tests

lib/k8s-test-framework/src/kubernetes_version.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ pub async fn get(kubectl_command: &str) -> Result<K8sVersion> {
2323
let json: serde_json::Value = serde_json::from_slice(&reader.stdout)?;
2424

2525
Ok(K8sVersion {
26-
major: json["serverVersion"]["major"].to_string().replace("\"", ""),
27-
minor: json["serverVersion"]["minor"].to_string().replace("\"", ""),
26+
major: json["serverVersion"]["major"].to_string().replace('\"', ""),
27+
minor: json["serverVersion"]["minor"].to_string().replace('\"', ""),
2828
platform: json["serverVersion"]["platform"]
2929
.to_string()
30-
.replace("\"", ""),
30+
.replace('\"', ""),
3131
git_version: json["serverVersion"]["gitVersion"]
3232
.to_string()
33-
.replace("\"", ""),
33+
.replace('\"', ""),
3434
})
3535
}
3636

lib/lookup/src/lookup_buf/segmentbuf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Arbitrary for FieldBuf {
6464
let name = (0..len)
6565
.map(|_| chars[usize::arbitrary(g) % chars.len()])
6666
.collect::<String>()
67-
.replace(r#"""#, r#"\""#);
67+
.replace('"', r#"\""#);
6868
FieldBuf::from(name)
6969
}
7070

@@ -74,7 +74,7 @@ impl Arbitrary for FieldBuf {
7474
.shrink()
7575
.filter(|name| !name.is_empty())
7676
.map(|name| {
77-
let name = name.replace(r#"""#, r#"/""#);
77+
let name = name.replace('"', r#"/""#);
7878
FieldBuf::from(name)
7979
}),
8080
)

lib/value/src/value/api.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::use_self)] // I don't think Self can be used here, it creates a cycle
2+
13
use async_graphql::scalar;
24

35
use crate::value::Value;

lib/value/src/value/display.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ impl fmt::Display for Value {
99
f,
1010
r#""{}""#,
1111
String::from_utf8_lossy(val)
12-
.replace(r#"\"#, r#"\\"#)
13-
.replace(r#"""#, r#"\""#)
14-
.replace("\n", r#"\n"#)
12+
.replace('\\', r#"\\"#)
13+
.replace('"', r#"\""#)
14+
.replace('\n', r#"\n"#)
1515
),
1616
Value::Integer(val) => write!(f, "{}", val),
1717
Value::Float(val) => write!(f, "{}", val),

0 commit comments

Comments
 (0)