Skip to content

Commit 7feb260

Browse files
committed
style: clippy and fmt with new rules
1 parent 63e8a4b commit 7feb260

File tree

11 files changed

+25
-25
lines changed

11 files changed

+25
-25
lines changed

src/exporters/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ impl fmt::Display for MetricValueType {
7373
match &self {
7474
// MetricValueType::IntSigned(value) => write!(f, "{}", value),
7575
// MetricValueType::Float(value) => write!(f, "{}", value),
76-
MetricValueType::Text(text) => write!(f, "{}", text),
77-
MetricValueType::FloatDouble(value) => write!(f, "{}", value),
78-
MetricValueType::IntUnsigned(value) => write!(f, "{}", value),
76+
MetricValueType::Text(text) => write!(f, "{text}"),
77+
MetricValueType::FloatDouble(value) => write!(f, "{value}"),
78+
MetricValueType::IntUnsigned(value) => write!(f, "{value}"),
7979
}
8080
}
8181
}
@@ -85,9 +85,9 @@ impl fmt::Debug for MetricValueType {
8585
match &self {
8686
// MetricValueType::IntSigned(value) => write!(f, "{}", value),
8787
// MetricValueType::Float(value) => write!(f, "{}", value),
88-
MetricValueType::Text(text) => write!(f, "{}", text),
89-
MetricValueType::FloatDouble(value) => write!(f, "{}", value),
90-
MetricValueType::IntUnsigned(value) => write!(f, "{}", value),
88+
MetricValueType::Text(text) => write!(f, "{text}"),
89+
MetricValueType::FloatDouble(value) => write!(f, "{value}"),
90+
MetricValueType::IntUnsigned(value) => write!(f, "{value}"),
9191
}
9292
}
9393
}

src/exporters/prometheus.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ fn format_metric(key: &str, value: &str, labels: Option<&HashMap<String, String>
200200
result.remove(result.len() - 1);
201201
result.push('}');
202202
}
203-
let _ = writeln!(result, " {}", value);
203+
let _ = writeln!(result, " {value}");
204204
result
205205
}
206206

@@ -214,8 +214,8 @@ fn push_metric(
214214
add_help: bool,
215215
) -> String {
216216
if add_help {
217-
let _ = write!(body, "# HELP {} {}", metric_name, help);
218-
let _ = write!(body, "\n# TYPE {} {}\n", metric_name, metric_type);
217+
let _ = write!(body, "# HELP {metric_name} {help}");
218+
let _ = write!(body, "\n# TYPE {metric_name} {metric_type}\n");
219219
}
220220
body.push_str(&metric_line);
221221
body
@@ -288,7 +288,7 @@ async fn show_metrics(
288288
);
289289
}
290290
} else {
291-
let _ = write!(body, "<a href=\"https://github.com/hubblo-org/scaphandre/\">Scaphandre's</a> prometheus exporter here. Metrics available on <a href=\"/{}\">/{}</a>", suffix, suffix);
291+
let _ = write!(body, "<a href=\"https://github.com/hubblo-org/scaphandre/\">Scaphandre's</a> prometheus exporter here. Metrics available on <a href=\"/{suffix}\">/{suffix}</a>");
292292
}
293293
Ok(Response::new(body.into()))
294294
}

src/exporters/qemu.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl QemuExporter {
7373
);
7474
let time_pdiff = last.total_time_jiffies() - previous.total_time_jiffies();
7575
if let Some(time_tdiff) = &topo_stat_diff {
76-
let first_domain_path = format!("{}/{}/intel-rapl:0:0", path, vm_name);
76+
let first_domain_path = format!("{path}/{vm_name}/intel-rapl:0:0");
7777
if fs::read_dir(&first_domain_path).is_err() {
7878
match fs::create_dir_all(&first_domain_path) {
7979
Ok(_) => info!("Created {} folder.", &path),
@@ -86,7 +86,7 @@ impl QemuExporter {
8686
trace!("Ratio is {}", ratio.to_string());
8787
let uj_to_add = ratio * topo_rec_uj.value.parse::<u64>().unwrap();
8888
trace!("Adding {} uJ", uj_to_add);
89-
let complete_path = format!("{}/{}/intel-rapl:0", path, vm_name);
89+
let complete_path = format!("{path}/{vm_name}/intel-rapl:0");
9090
if let Ok(result) = QemuExporter::add_or_create(&complete_path, uj_to_add) {
9191
trace!("{:?}", result);
9292
debug!("Updated {}", complete_path);

src/exporters/riemann.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl Exporter for RiemannExporter {
136136
Utc::now().format("%Y-%m-%dT%H:%M:%S")
137137
);
138138
println!("Press CTRL-C to stop scaphandre");
139-
println!("Measurement step is: {}s", dispatch_duration);
139+
println!("Measurement step is: {dispatch_duration}s");
140140

141141
let topology = self.sensor.get_topology().unwrap();
142142
let mut metric_generator = MetricGenerator::new(

src/exporters/stdout.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl StdoutExporter {
127127
parameters.is_present("containers"),
128128
);
129129

130-
println!("Measurement step is: {}s", step_duration);
130+
println!("Measurement step is: {step_duration}s");
131131
if timeout_secs == 0 {
132132
loop {
133133
self.iterate(&regex_filter, process_number, &mut metric_generator);
@@ -179,7 +179,7 @@ impl StdoutExporter {
179179

180180
println!(
181181
"Host:\t{} W",
182-
(format!("{}", host_power).parse::<f64>().unwrap() / 1000000.0)
182+
(format!("{host_power}").parse::<f64>().unwrap() / 1000000.0)
183183
);
184184

185185
if domain_names.is_some() {
@@ -197,7 +197,7 @@ impl StdoutExporter {
197197
}
198198
let socket_id = s.attributes.get("socket_id").unwrap().clone();
199199

200-
let mut to_print = format!("Socket{}\t{} W |\t", socket_id, power_str);
200+
let mut to_print = format!("Socket{socket_id}\t{power_str} W |\t");
201201

202202
let domains = metrics.iter().filter(|x| {
203203
x.name == "scaph_domain_power_microwatts"
@@ -232,7 +232,7 @@ impl StdoutExporter {
232232
to_print.push_str("---");
233233
}
234234
}
235-
println!("{}\n", to_print);
235+
println!("{to_print}\n");
236236
}
237237
}
238238

@@ -244,7 +244,7 @@ impl StdoutExporter {
244244
.proc_tracker
245245
.get_filtered_processes(regex_filter);
246246
} else {
247-
println!("Top {} consumers:", process_number);
247+
println!("Top {process_number} consumers:");
248248
consumers = metric_generator
249249
.topology
250250
.proc_tracker

src/exporters/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn get_scaphandre_version() -> String {
4343
let major_version = version_parts.next().unwrap();
4444
let patch_version = version_parts.next().unwrap();
4545
let minor_version = version_parts.next().unwrap();
46-
format!("{}.{}{}", major_version, patch_version, minor_version)
46+
format!("{major_version}.{patch_version}{minor_version}")
4747
}
4848

4949
/// Returns the hostname of the system running Scaphandre.
@@ -116,7 +116,7 @@ pub fn get_kubernetes_client() -> Result<Kubernetes, KubernetesError> {
116116
) {
117117
Ok(kubernetes) => Ok(kubernetes),
118118
Err(err) => {
119-
eprintln!("Got Kubernetes error: {} | {:?}", err, err);
119+
eprintln!("Got Kubernetes error: {err} | {err:?}");
120120
Err(err)
121121
}
122122
}

src/exporters/warpten.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl Warp10Exporter {
131131
//read_token: Option<&str>,
132132
qemu: bool,
133133
) -> Result<Vec<warp10::Warp10Response>, warp10::Error> {
134-
let client = warp10::Client::new(&format!("{}://{}:{}", scheme, host, port))?;
134+
let client = warp10::Client::new(&format!("{scheme}://{host}:{port}"))?;
135135
let writer = client.get_writer(write_token.to_string());
136136
self.topology
137137
.proc_tracker

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn current_system_time_since_epoch() -> Duration {
182182
}
183183

184184
pub fn scaphandre_header(exporter_name: &str) {
185-
let title = format!("Scaphandre {} exporter", exporter_name);
185+
let title = format!("Scaphandre {exporter_name} exporter");
186186
println!("{}", title.red().bold());
187187
println!("Sending ⚡ metrics");
188188
}

src/sensors/powercap_rapl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl Sensor for PowercapRAPLSensor {
143143
self.base_path, socket_id, domain_id
144144
),
145145
);
146-
if let Ok(domain_name) = &fs::read_to_string(format!("{}/name", folder_name)) {
146+
if let Ok(domain_name) = &fs::read_to_string(format!("{folder_name}/name")) {
147147
topo.safe_add_domain_to_socket(
148148
socket_id,
149149
domain_id,

src/sensors/units.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl fmt::Display for Unit {
7070
impl Eq for Unit {}
7171
impl PartialEq for Unit {
7272
fn eq(&self, other: &Self) -> bool {
73-
format!("{:?}", self) == format!("{:?}", other)
73+
format!("{self:?}") == format!("{other:?}")
7474
}
7575
}
7676

0 commit comments

Comments
 (0)