Skip to content

Commit a26e7f3

Browse files
authored
Assorted clippy fixes (#1043)
* clippy: blacklisted-names is deprecated in favor of disallowed-names Signed-off-by: Cyril Plisko <[email protected]> * clippy::needless_borrow Signed-off-by: Cyril Plisko <[email protected]> * clippy::needless_lifetimes Signed-off-by: Cyril Plisko <[email protected]> * clippy::redundant_clone Signed-off-by: Cyril Plisko <[email protected]> * clippy::explicit_auto_deref Signed-off-by: Cyril Plisko <[email protected]> * clippy::iter_kv_map Signed-off-by: Cyril Plisko <[email protected]> * clippy::bool_assert_comparison Signed-off-by: Cyril Plisko <[email protected]> * clippy::derive_partial_eq_without_eq Signed-off-by: Cyril Plisko <[email protected]> Signed-off-by: Cyril Plisko <[email protected]>
1 parent d6b33ce commit a26e7f3

File tree

14 files changed

+34
-34
lines changed

14 files changed

+34
-34
lines changed

clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
blacklisted-names = []
1+
disallowed-names = []

examples/crd_derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
99
/// Our spec for Foo
1010
///
1111
/// A struct with our chosen Kind will be created for us, using the following kube attrs
12-
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Clone, JsonSchema)]
12+
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, JsonSchema)]
1313
#[kube(
1414
group = "clux.dev",
1515
version = "v1",

examples/crd_derive_schema.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
1919
// - https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#defaulting
2020
// - https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#defaulting-and-nullable
2121

22-
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Clone, JsonSchema)]
22+
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, JsonSchema)]
2323
#[kube(
2424
group = "clux.dev",
2525
version = "v1",

examples/custom_client_trace.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ async fn main() -> anyhow::Result<()> {
4242
})
4343
.on_response(|response: &Response<Body>, latency: Duration, span: &Span| {
4444
let status = response.status();
45-
span.record("http.status_code", &status.as_u16());
45+
span.record("http.status_code", status.as_u16());
4646
if status.is_client_error() || status.is_server_error() {
47-
span.record("otel.status_code", &"ERROR");
47+
span.record("otel.status_code", "ERROR");
4848
}
4949
tracing::debug!("finished in {}ms", latency.as_millis())
5050
}),

examples/dynamic_jsonpath.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ async fn main() -> anyhow::Result<()> {
2020
);
2121

2222
let pods: Api<Pod> = Api::<Pod>::all(client);
23-
let list_params = ListParams::default().fields(&*field_selector);
23+
let list_params = ListParams::default().fields(&field_selector);
2424
let list = pods.list(&list_params).await?;
2525

2626
// Use the given JSONPATH to filter the ObjectList
2727
let list_json = serde_json::to_value(&list)?;
28-
let res = jsonpath_lib::select(&list_json, &*jsonpath).unwrap();
28+
let res = jsonpath_lib::select(&list_json, &jsonpath).unwrap();
2929
info!("\t\t {:?}", res);
3030
Ok(())
3131
}

examples/pod_cp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async fn main() -> anyhow::Result<()> {
5858
// Write the data to pod
5959
{
6060
let mut header = tar::Header::new_gnu();
61-
header.set_path(&file_name).unwrap();
61+
header.set_path(file_name).unwrap();
6262
header.set_size(data.len() as u64);
6363
header.set_cksum();
6464

kube-client/src/api/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,6 @@ mod test {
254254
let _: Api<corev1::Node> = Api::all(client.clone());
255255
let _: Api<corev1::Pod> = Api::default_namespaced(client.clone());
256256
let _: Api<corev1::PersistentVolume> = Api::all(client.clone());
257-
let _: Api<corev1::ConfigMap> = Api::namespaced(client.clone(), "default");
257+
let _: Api<corev1::ConfigMap> = Api::namespaced(client, "default");
258258
}
259259
}

kube-client/src/client/builder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ impl TryFrom<Config> for ClientBuilder<BoxService<Request<hyper::Body>, Response
143143
})
144144
.on_response(|res: &Response<hyper::Body>, _latency: Duration, span: &Span| {
145145
let status = res.status();
146-
span.record("http.status_code", &status.as_u16());
146+
span.record("http.status_code", status.as_u16());
147147
if status.is_client_error() || status.is_server_error() {
148-
span.record("otel.status_code", &"ERROR");
148+
span.record("otel.status_code", "ERROR");
149149
}
150150
})
151151
// Explicitly disable `on_body_chunk`. The default does nothing.
@@ -159,10 +159,10 @@ impl TryFrom<Config> for ClientBuilder<BoxService<Request<hyper::Body>, Response
159159
// - Polling `Body` errored
160160
// - the response was classified as failure (5xx)
161161
// - End of stream was classified as failure
162-
span.record("otel.status_code", &"ERROR");
162+
span.record("otel.status_code", "ERROR");
163163
match ec {
164164
ServerErrorsFailureClass::StatusCode(status) => {
165-
span.record("http.status_code", &status.as_u16());
165+
span.record("http.status_code", status.as_u16());
166166
tracing::error!("failed with status {}", status)
167167
}
168168
ServerErrorsFailureClass::Error(err) => {

kube-client/src/config/file_config.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct Kubeconfig {
5151

5252
/// Preferences stores extensions for cli.
5353
#[derive(Clone, Debug, Serialize, Deserialize)]
54-
#[cfg_attr(test, derive(PartialEq))]
54+
#[cfg_attr(test, derive(PartialEq, Eq))]
5555
pub struct Preferences {
5656
/// Enable colors
5757
#[serde(skip_serializing_if = "Option::is_none")]
@@ -63,7 +63,7 @@ pub struct Preferences {
6363

6464
/// NamedExtention associates name with extension.
6565
#[derive(Clone, Debug, Serialize, Deserialize)]
66-
#[cfg_attr(test, derive(PartialEq))]
66+
#[cfg_attr(test, derive(PartialEq, Eq))]
6767
pub struct NamedExtension {
6868
/// Name of extension
6969
pub name: String,
@@ -73,7 +73,7 @@ pub struct NamedExtension {
7373

7474
/// NamedCluster associates name with cluster.
7575
#[derive(Clone, Debug, Serialize, Deserialize)]
76-
#[cfg_attr(test, derive(PartialEq))]
76+
#[cfg_attr(test, derive(PartialEq, Eq))]
7777
pub struct NamedCluster {
7878
/// Name of cluster
7979
pub name: String,
@@ -83,7 +83,7 @@ pub struct NamedCluster {
8383

8484
/// Cluster stores information to connect Kubernetes cluster.
8585
#[derive(Clone, Debug, Serialize, Deserialize)]
86-
#[cfg_attr(test, derive(PartialEq))]
86+
#[cfg_attr(test, derive(PartialEq, Eq))]
8787
pub struct Cluster {
8888
/// The address of the kubernetes cluster (https://hostname:port).
8989
pub server: String,
@@ -209,13 +209,13 @@ pub struct AuthInfo {
209209
#[cfg(test)]
210210
impl PartialEq for AuthInfo {
211211
fn eq(&self, other: &Self) -> bool {
212-
serde_json::to_value(&self).unwrap() == serde_json::to_value(&other).unwrap()
212+
serde_json::to_value(self).unwrap() == serde_json::to_value(other).unwrap()
213213
}
214214
}
215215

216216
/// AuthProviderConfig stores auth for specified cloud provider.
217217
#[derive(Clone, Debug, Serialize, Deserialize)]
218-
#[cfg_attr(test, derive(PartialEq))]
218+
#[cfg_attr(test, derive(PartialEq, Eq))]
219219
pub struct AuthProviderConfig {
220220
/// Name of the auth provider
221221
pub name: String,
@@ -225,7 +225,7 @@ pub struct AuthProviderConfig {
225225

226226
/// ExecConfig stores credential-plugin configuration.
227227
#[derive(Clone, Debug, Serialize, Deserialize)]
228-
#[cfg_attr(test, derive(PartialEq))]
228+
#[cfg_attr(test, derive(PartialEq, Eq))]
229229
pub struct ExecConfig {
230230
/// Preferred input version of the ExecInfo.
231231
///
@@ -247,7 +247,7 @@ pub struct ExecConfig {
247247

248248
/// NamedContext associates name with context.
249249
#[derive(Clone, Debug, Serialize, Deserialize)]
250-
#[cfg_attr(test, derive(PartialEq))]
250+
#[cfg_attr(test, derive(PartialEq, Eq))]
251251
pub struct NamedContext {
252252
/// Name of the context
253253
pub name: String,
@@ -257,7 +257,7 @@ pub struct NamedContext {
257257

258258
/// Context stores tuple of cluster and user information.
259259
#[derive(Clone, Debug, Serialize, Deserialize)]
260-
#[cfg_attr(test, derive(PartialEq))]
260+
#[cfg_attr(test, derive(PartialEq, Eq))]
261261
pub struct Context {
262262
/// Name of the cluster for this context
263263
pub cluster: String,

kube-client/src/discovery/apigroup.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ impl ApiGroup {
275275
})
276276
});
277277
lookup
278-
.into_iter()
279-
.map(|(_, mut v)| {
278+
.into_values()
279+
.map(|mut v| {
280280
v.sort_by_cached_key(|(ar, _)| Reverse(Version::parse(ar.version.as_str()).priority()));
281281
v[0].to_owned()
282282
})
@@ -353,15 +353,15 @@ mod tests {
353353
data: vec![
354354
GroupVersionData {
355355
version: "v1alpha1".to_string(),
356-
resources: vec![(testlowversioncr_v1alpha1.clone(), ac.clone())],
356+
resources: vec![(testlowversioncr_v1alpha1, ac.clone())],
357357
},
358358
GroupVersionData {
359359
version: "v1".to_string(),
360-
resources: vec![(testcr_v1.clone(), ac.clone())],
360+
resources: vec![(testcr_v1, ac.clone())],
361361
},
362362
GroupVersionData {
363363
version: "v2alpha1".to_string(),
364-
resources: vec![(testcr_v2alpha1.clone(), ac.clone())],
364+
resources: vec![(testcr_v2alpha1, ac)],
365365
},
366366
],
367367
preferred: Some(String::from("v1")),

kube-core/src/admission.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ pub enum Operation {
234234
/// .into_review();
235235
///
236236
/// ```
237-
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
237+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
238238
#[serde(rename_all = "camelCase")]
239239
#[non_exhaustive]
240240
pub struct AdmissionResponse {

kube-core/src/object.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<T: Clone> ObjectList<T> {
4747
/// let first = objectlist.iter().next();
4848
/// println!("First element: {:?}", first); // prints "First element: Some(1)"
4949
/// ```
50-
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &T> + 'a {
50+
pub fn iter(&self) -> impl Iterator<Item = &T> {
5151
self.items.iter()
5252
}
5353

@@ -70,7 +70,7 @@ impl<T: Clone> ObjectList<T> {
7070
/// println!("First element: {:?}", elem); // prints "First element: 2"
7171
/// }
7272
73-
pub fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &mut T> + 'a {
73+
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
7474
self.items.iter_mut()
7575
}
7676
}

kube-core/src/response.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use serde::{Deserialize, Serialize};
33

44
/// A Kubernetes status object
5-
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
5+
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq)]
66
pub struct Status {
77
/// Status of the operation
88
///
@@ -95,7 +95,7 @@ pub enum StatusSummary {
9595
}
9696

9797
/// Status details object on the [`Status`] object
98-
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
98+
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
9999
#[serde(rename_all = "camelCase")]
100100
pub struct StatusDetails {
101101
/// The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described)
@@ -133,7 +133,7 @@ pub struct StatusDetails {
133133
}
134134

135135
/// Status cause object on the [`StatusDetails`] object
136-
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
136+
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
137137
pub struct StatusCause {
138138
/// A machine-readable description of the cause of the error. If this value is empty there is no information available.
139139
#[serde(default, skip_serializing_if = "String::is_empty")]

kube-derive/src/custom_resource.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,6 @@ mod tests {
608608
assert_eq!(kube_attrs.group, "clux.dev".to_string());
609609
assert_eq!(kube_attrs.version, "v1".to_string());
610610
assert_eq!(kube_attrs.kind, "Foo".to_string());
611-
assert_eq!(kube_attrs.namespaced, true);
611+
assert!(kube_attrs.namespaced);
612612
}
613613
}

0 commit comments

Comments
 (0)