Skip to content

Commit 0a99c46

Browse files
committed
Fix clippy 1.67.0 warnings (#555)
## Description Fix warnings of clippy 1.67.0. We have not bumped yet but I'm fixing them early on Please review commits individually
1 parent 707b043 commit 0a99c46

File tree

11 files changed

+35
-44
lines changed

11 files changed

+35
-44
lines changed

src/builder/pod/container.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ impl fmt::Display for FieldPathEnvVar {
323323
FieldPathEnvVar::Name => write!(f, "metadata.name"),
324324
FieldPathEnvVar::Namespace => write!(f, "metadata.namespace"),
325325
FieldPathEnvVar::UID => write!(f, "metadata.uid"),
326-
FieldPathEnvVar::Labels(name) => write!(f, "metadata.labels['{}']", name),
327-
FieldPathEnvVar::Annotations(name) => write!(f, "metadata.annotations['{}']", name),
326+
FieldPathEnvVar::Labels(name) => write!(f, "metadata.labels['{name}']"),
327+
FieldPathEnvVar::Annotations(name) => write!(f, "metadata.annotations['{name}']"),
328328
}
329329
}
330330
}

src/cli.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ impl ProductConfigPath {
224224
self.path.as_deref(),
225225
default_search_paths,
226226
)?)
227-
.map_err(|source| error::Error::ProductConfigLoadError { source })
227+
.map_err(|source| error::Error::ProductConfigLoadError {
228+
source: source.into(),
229+
})
228230
}
229231
}
230232

src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Client {
5757
// According to https://kubernetes.io/docs/reference/using-api/server-side-apply/#using-server-side-apply-in-a-controller we should always force conflicts in controllers.
5858
params.force = true;
5959
if let Some(manager) = &mut params.field_manager {
60-
*manager = format!("{}/{}", manager, field_manager_scope);
60+
*manager = format!("{manager}/{field_manager_scope}");
6161
}
6262
params
6363
}

src/commons/opa.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,10 @@ mod tests {
319319
apiVersion: test/v1
320320
kind: TestCluster
321321
metadata:
322-
name: {}
322+
name: {CLUSTER_NAME}
323323
spec:
324324
test: 100
325-
",
326-
CLUSTER_NAME
325+
"
327326
))
328327
.unwrap()
329328
}

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub enum Error {
5555
#[error("Failed to load ProductConfig: {source}")]
5656
ProductConfigLoadError {
5757
#[source]
58-
source: product_config::error::Error,
58+
source: Box<product_config::error::Error>,
5959
},
6060

6161
#[error("ProductConfig Framework reported error: {source}")]

src/label_selector.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn convert_label_selector_to_query_string(
1818
query_string.push_str(
1919
&label_map
2020
.iter()
21-
.map(|(key, value)| format!("{}={}", key, value))
21+
.map(|(key, value)| format!("{key}={value}"))
2222
.collect::<Vec<_>>()
2323
.join(","),
2424
);
@@ -51,8 +51,7 @@ pub fn convert_label_selector_to_query_string(
5151
)),
5252
_ => Err(Error::InvalidLabelSelector {
5353
message: format!(
54-
"LabelSelector has no or empty values for [{}] operator",
55-
operator
54+
"LabelSelector has no or empty values for [{operator}] operator"
5655
),
5756
}),
5857
},
@@ -75,7 +74,7 @@ pub fn convert_label_selector_to_query_string(
7574
op => {
7675
Err(
7776
Error::InvalidLabelSelector {
78-
message: format!("LabelSelector has illegal/unknown operator [{}]", op)
77+
message: format!("LabelSelector has illegal/unknown operator [{op}]")
7978
})
8079
}
8180
})

src/logging/k8s_events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn error_to_event<E: ReconcilerError>(err: &E) -> Event {
2121
loop {
2222
err = match err.source() {
2323
Some(err) => {
24-
write!(buf, ": {}", err).unwrap();
24+
write!(buf, ": {err}").unwrap();
2525
err
2626
}
2727
None => break buf,

src/memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub fn to_java_heap_value(
128128
if scaled.value < 1.0 {
129129
Err(Error::CannotConvertToJavaHeapValue {
130130
value: q.0.to_owned(),
131-
target_unit: format!("{:?}", target_unit),
131+
target_unit: format!("{target_unit:?}"),
132132
})
133133
} else {
134134
Ok(scaled.value as u32)

src/product_config_utils.rs

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub type ValidatedRoleConfigByPropertyKind =
111111
/// # Arguments
112112
/// - `role` - The role name.
113113
/// - `group` - The role group name.
114-
/// - `role_config` - The validated product configuration for each role and group.
114+
/// - `role_config` - The validated product configuration for each role and group.
115115
pub fn config_for_role_and_group<'a>(
116116
role: &str,
117117
group: &str,
@@ -166,7 +166,7 @@ where
166166
}
167167

168168
/// Validates a product configuration for all roles and role_groups. Requires a valid product config
169-
/// and [`RoleConfigByPropertyKind`] which can be obtained via `transform_all_roles_to_config`.
169+
/// and [`RoleConfigByPropertyKind`] which can be obtained via `transform_all_roles_to_config`.
170170
///
171171
/// # Arguments
172172
/// - `version` - The version of the product to be configured.
@@ -209,7 +209,7 @@ pub fn validate_all_roles_and_groups_config(
209209

210210
/// Calculates and validates a product configuration for a role and group. Requires a valid
211211
/// product config and existing [`RoleConfigByPropertyKind`] that can be obtained via
212-
/// `transform_all_roles_to_config`.
212+
/// `transform_all_roles_to_config`.
213213
///
214214
/// # Arguments
215215
/// - `role` - The name of the role
@@ -1223,46 +1223,37 @@ mod tests {
12231223
spec:
12241224
units: []
12251225
properties:
1226-
- property:
1226+
- property:
12271227
propertyNames:
1228-
- name: \"{}\"
1228+
- name: \"{pc_name}\"
12291229
kind:
12301230
type: \"file\"
1231-
file: \"{}\"
1231+
file: \"{file_name}\"
12321232
datatype:
12331233
type: \"string\"
12341234
recommendedValues:
1235-
- value: \"{}\"
1235+
- value: \"{pc_value}\"
12361236
roles:
1237-
- name: \"{}\"
1237+
- name: \"{role_1}\"
12381238
required: true
1239-
- name: \"{}\"
1239+
- name: \"{role_2}\"
12401240
required: true
12411241
asOfVersion: \"0.0.0\"
1242-
- property:
1242+
- property:
12431243
propertyNames:
1244-
- name: \"{}\"
1244+
- name: \"{pc_bad_version}\"
12451245
kind:
12461246
type: \"file\"
1247-
file: \"{}\"
1247+
file: \"{file_name}\"
12481248
datatype:
12491249
type: \"string\"
12501250
recommendedValues:
1251-
- value: \"{}\"
1251+
- value: \"{pc_bad_version_value}\"
12521252
roles:
1253-
- name: \"{}\"
1253+
- name: \"{role_1}\"
12541254
required: true
12551255
asOfVersion: \"0.5.0\"
1256-
",
1257-
pc_name,
1258-
file_name,
1259-
pc_value,
1260-
role_1,
1261-
role_2,
1262-
pc_bad_version,
1263-
file_name,
1264-
pc_bad_version_value,
1265-
role_1
1256+
"
12661257
);
12671258

12681259
let product_config = ProductConfigManager::from_str(config).unwrap();

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn print_startup_string(
3737
) {
3838
let git_information = match git_version {
3939
None => "".to_string(),
40-
Some(git) => format!(" (Git information: {})", git),
40+
Some(git) => format!(" (Git information: {git})"),
4141
};
4242
info!("Starting {}", pkg_description);
4343
info!(

src/validation.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ const RFC_1035_LABEL_MAX_LENGTH: usize = 63;
3232

3333
lazy_static! {
3434
static ref RFC_1123_SUBDOMAIN_REGEX: Regex =
35-
Regex::new(&format!("^{}$", RFC_1123_SUBDOMAIN_FMT)).unwrap();
35+
Regex::new(&format!("^{RFC_1123_SUBDOMAIN_FMT}$")).unwrap();
3636
static ref RFC_1123_LABEL_REGEX: Regex =
37-
Regex::new(&format!("^{}$", RFC_1123_SUBDOMAIN_FMT)).unwrap();
37+
Regex::new(&format!("^{RFC_1123_SUBDOMAIN_FMT}$")).unwrap();
3838
static ref RFC_1035_LABEL_REGEX: Regex =
39-
Regex::new(&format!("^{}$", RFC_1035_LABEL_FMT)).unwrap();
39+
Regex::new(&format!("^{RFC_1035_LABEL_FMT}$")).unwrap();
4040
}
4141

4242
/// Returns a formatted error message for maximum length violations.
4343
fn max_len_error(length: usize) -> String {
44-
format!("must be no more than {} characters", length)
44+
format!("must be no more than {length} characters")
4545
}
4646

4747
/// Returns a formatted error message for regex violations.
@@ -53,7 +53,7 @@ fn max_len_error(length: usize) -> String {
5353
/// * `examples` - are optional well, formed examples that would match the regex
5454
fn regex_error(msg: &str, fmt: &str, examples: &[&str]) -> String {
5555
if examples.is_empty() {
56-
return format!("{} (regex used for validation is '{}')", msg, fmt);
56+
return format!("{msg} (regex used for validation is '{fmt}')");
5757
}
5858

5959
let mut msg = msg.to_string();

0 commit comments

Comments
 (0)