Skip to content

Commit 96ff39d

Browse files
committed
rustfmt & clippy
1 parent 550abac commit 96ff39d

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed

sentry/src/application.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::{net::{IpAddr, Ipv4Addr, SocketAddr}, path::Path};
1+
use std::{
2+
net::{IpAddr, Ipv4Addr, SocketAddr},
3+
path::Path,
4+
};
25

36
use adapter::client::Locked;
47
use hyper::{
@@ -9,7 +12,7 @@ use once_cell::sync::Lazy;
912
use primitives::{config::Environment, ValidatorId};
1013
use redis::ConnectionInfo;
1114
use serde::{Deserialize, Deserializer};
12-
use simple_hyper_server_tls::{listener_from_pem_files, TlsListener, Protocols};
15+
use simple_hyper_server_tls::{listener_from_pem_files, Protocols, TlsListener};
1316
use slog::{error, info};
1417

1518
use crate::{
@@ -185,7 +188,7 @@ impl<C: Locked + 'static> Application<C> {
185188
if let Err(e) = server.await {
186189
error!(&logger, "server error: {}", e; "main" => "run");
187190
}
188-
},
191+
}
189192
EnableTls::Tls { listener, .. } => {
190193
let make_service = make_service_fn(|_| {
191194
let server = self.clone();
@@ -204,7 +207,7 @@ impl<C: Locked + 'static> Application<C> {
204207
// This is usually caused by trying to connect on HTTP instead of HTTPS
205208
error!(&logger, "server error: {}", e; "main" => "run");
206209
}
207-
},
210+
}
208211
}
209212
}
210213
}
@@ -229,12 +232,17 @@ pub enum EnableTls {
229232
Tls {
230233
socket_addr: SocketAddr,
231234
listener: TlsListener,
232-
}
235+
},
233236
}
234237

235238
impl EnableTls {
236-
pub fn new_tls<C: AsRef<Path>, K: AsRef<Path>>(certificates: C, private_keys: K, socket_addr: SocketAddr) -> Result<Self, Box<dyn std::error::Error>> {
237-
let listener = listener_from_pem_files(certificates, private_keys, Protocols::ALL, &socket_addr)?;
239+
pub fn new_tls<C: AsRef<Path>, K: AsRef<Path>>(
240+
certificates: C,
241+
private_keys: K,
242+
socket_addr: SocketAddr,
243+
) -> Result<Self, Box<dyn std::error::Error>> {
244+
let listener =
245+
listener_from_pem_files(certificates, private_keys, Protocols::ALL, &socket_addr)?;
238246

239247
Ok(Self::Tls {
240248
listener,

sentry/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn setup_migrations(environment: Environment) {
9696

9797
// NOTE: Make sure to update list of migrations for the tests as well!
9898
// `tests_postgres::MIGRATIONS`
99-
let mut migrations = vec![make_migration!("20190806011140_initial-tables")];
99+
let migrations = vec![make_migration!("20190806011140_initial-tables")];
100100

101101
// if let Environment::Development = environment {
102102
// // seeds database tables for testing

sentry/src/db/channel.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ mod list_channels {
9090
let mut params_total: Vec<Box<(dyn ToSql + Send + Sync)>> = vec![];
9191

9292
if !chains.is_empty() {
93+
#[allow(clippy::type_complexity)]
9394
let (chain_params, chain_params_total): (
9495
Vec<Box<dyn ToSql + Send + Sync>>,
9596
Vec<Box<dyn ToSql + Send + Sync>>,
@@ -110,18 +111,15 @@ mod list_channels {
110111
where_clauses.push(format!("chain_id IN ({})", params_prepared));
111112
}
112113

113-
match validator {
114-
Some(validator) => {
115-
// params are 1-indexed
116-
where_clauses.push(format!(
117-
"(leader = ${validator_param} OR follower = ${validator_param})",
118-
validator_param = params.len() + 1
119-
));
120-
// then add the new param to the list!
121-
params.push(Box::new(validator) as _);
122-
params_total.push(Box::new(validator) as _);
123-
}
124-
_ => {}
114+
if let Some(validator) = validator {
115+
// params are 1-indexed
116+
where_clauses.push(format!(
117+
"(leader = ${validator_param} OR follower = ${validator_param})",
118+
validator_param = params.len() + 1
119+
));
120+
// then add the new param to the list!
121+
params.push(Box::new(validator) as _);
122+
params_total.push(Box::new(validator) as _);
125123
}
126124

127125
// To understand why we use Order by, see Postgres Documentation: https://www.postgresql.org/docs/8.1/queries-limit.html
@@ -169,7 +167,7 @@ limit, skip)
169167
where_clauses.join(" AND ")
170168
)
171169
} else {
172-
format!("SELECT COUNT(id)::varchar FROM channels")
170+
"SELECT COUNT(id)::varchar FROM channels".to_string()
173171
};
174172

175173
let stmt = client.prepare(&statement).await?;

sentry/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![deny(rust_2018_idioms)]
33

44
use adapter::{primitives::AdapterTypes, Adapter};
5-
use clap::{crate_version, Arg, Command, value_parser};
5+
use clap::{crate_version, value_parser, Arg, Command};
66

77
use primitives::{
88
config::configuration, postgres::POSTGRES_CONFIG, test_util::DUMMY_AUTH,

test_harness/src/deposits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ pub struct Deposit {
1111

1212
impl PartialEq<primitives::Deposit<BigNum>> for Deposit {
1313
fn eq(&self, other: &primitives::Deposit<BigNum>) -> bool {
14-
&self.outpace_amount == &other.total
14+
self.outpace_amount == other.total
1515
}
1616
}

0 commit comments

Comments
 (0)