Skip to content

Commit

Permalink
tree: fix clippy warnings
Browse files Browse the repository at this point in the history
This is a mix of both new and old clippy warnings. Just doing it in one
commit to make it easier.
  • Loading branch information
jlebon committed Nov 2, 2024
1 parent 5329303 commit 6b2985a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion commons/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn throttle_rollouts(input: Graph, client_wariness: f64) -> Graph {

for (index, release) in graph.nodes.iter().enumerate() {
// Skip if this release is not being rolled out.
if release.metadata.get(metadata::ROLLOUT).is_none() {
if !release.metadata.contains_key(metadata::ROLLOUT) {
continue;
};

Expand Down
11 changes: 6 additions & 5 deletions fcos-graph-builder/src/scraper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ impl Handler<RefreshTick> for Scraper {
g.into_iter()
.map(|(arch, graph)| (arch, false, graph))
.chain(oci_g.into_iter().map(|(arch, graph)| (arch, true, graph)))
.map(|(arch, oci, graph)| actor.update_cached_graph(arch, oci, graph))
.collect()
.try_for_each(|(arch, oci, graph)| {
actor.update_cached_graph(arch, oci, graph)
})
});
if let Err(e) = res {
log::error!("transient scraping failure: {}", e);
Expand Down Expand Up @@ -265,15 +266,15 @@ impl Handler<GetCachedGraph> for Scraper {
};
if let Some(graph) = target_graphmap.get(&msg.scope.basearch) {
crate::CACHED_GRAPH_REQUESTS
.with_label_values(&[&msg.scope.basearch, &msg.scope.stream, &graph_type])
.with_label_values(&[&msg.scope.basearch, &msg.scope.stream, graph_type])
.inc();

Box::new(actix::fut::ok(graph.clone()))
} else {
return Box::new(actix::fut::err(format_err!(
Box::new(actix::fut::err(format_err!(
"unexpected basearch '{}'",
msg.scope.basearch
)));
)))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion fcos-graph-builder/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Default for ServiceSettings {
origin_allowlist: None,
ip_addr: Self::DEFAULT_GB_SERVICE_ADDR.into(),
port: Self::DEFAULT_GB_SERVICE_PORT,
streams: Self::DEFAULT_STREAMS.iter().map(|&t| t).collect(),
streams: Self::DEFAULT_STREAMS.iter().copied().collect(),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions fcos-policy-engine/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn compute_wariness(params: &GraphQuery) -> f64 {
.unwrap_or_default()
.parse::<f64>()
{
let wariness = input.max(0.0).min(1.0);
let wariness = input.clamp(0.0, 1.0);
return wariness;
}

Expand All @@ -207,9 +207,9 @@ fn compute_wariness(params: &GraphQuery) -> f64 {
uuid.hash(&mut hasher);
let digest = hasher.finish();
// Scale down.
let scaled = (digest as f64) / (std::u64::MAX as f64);
let scaled = (digest as f64) / (u64::MAX as f64);
// Clamp within limits.
scaled.max(COMPUTED_MIN).min(COMPUTED_MAX)
scaled.clamp(COMPUTED_MIN, COMPUTED_MAX)
};

wariness
Expand Down

0 comments on commit 6b2985a

Please sign in to comment.