Skip to content

Commit d3fdf34

Browse files
authored
cargo clippy (#392)
1 parent bec7d22 commit d3fdf34

File tree

11 files changed

+31
-45
lines changed

11 files changed

+31
-45
lines changed

refinery/tests/mysql.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ mod mysql {
125125
let mut conn = pool.get_conn().unwrap();
126126
embedded::migrations::runner().run(&mut conn).unwrap();
127127
for row in format!(
128-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
129-
DEFAULT_TABLE_NAME
128+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
130129
)
131130
.run(conn)
132131
.unwrap()
@@ -150,8 +149,7 @@ mod mysql {
150149
.unwrap();
151150

152151
for row in format!(
153-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
154-
DEFAULT_TABLE_NAME
152+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
155153
)
156154
.run(conn)
157155
.unwrap()

refinery/tests/mysql_async.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ mod mysql_async {
9595
.unwrap();
9696

9797
conn.query(format!(
98-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
99-
DEFAULT_TABLE_NAME
98+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
10099
))
101100
.await
102101
.unwrap()
@@ -123,8 +122,7 @@ mod mysql_async {
123122

124123
let result = conn
125124
.query(format!(
126-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
127-
DEFAULT_TABLE_NAME
125+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
128126
))
129127
.await
130128
.unwrap();

refinery/tests/postgres.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ mod postgres {
130130
for row in &client
131131
.query(
132132
&format!(
133-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
134-
DEFAULT_TABLE_NAME
133+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
135134
),
136135
&[],
137136
)
@@ -156,8 +155,7 @@ mod postgres {
156155
for row in &client
157156
.query(
158157
&format!(
159-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
160-
DEFAULT_TABLE_NAME
158+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
161159
),
162160
&[],
163161
)
@@ -295,7 +293,7 @@ mod postgres {
295293
let result = broken::migrations::runner().run(&mut client);
296294

297295
assert!(result.is_err());
298-
println!("CURRENT: {:?}", result);
296+
println!("CURRENT: {result:?}");
299297

300298
let current = client
301299
.get_last_applied_migration(DEFAULT_TABLE_NAME)
@@ -341,7 +339,7 @@ mod postgres {
341339
.run(&mut client);
342340

343341
assert!(result.is_err());
344-
println!("CURRENT: {:?}", result);
342+
println!("CURRENT: {result:?}");
345343

346344
let query = &client
347345
.query("SELECT version FROM refinery_schema_history", &[])

refinery/tests/rusqlite.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ mod rusqlite {
141141
let table_name: String = conn
142142
.query_row(
143143
&format!(
144-
"SELECT name FROM sqlite_master WHERE type='table' AND name='{}'",
145-
DEFAULT_TABLE_NAME
144+
"SELECT name FROM sqlite_master WHERE type='table' AND name='{DEFAULT_TABLE_NAME}'",
146145
),
147146
[],
148147
|row| row.get(0),
@@ -161,8 +160,7 @@ mod rusqlite {
161160
let table_name: String = conn
162161
.query_row(
163162
&format!(
164-
"SELECT name FROM sqlite_master WHERE type='table' AND name='{}'",
165-
DEFAULT_TABLE_NAME
163+
"SELECT name FROM sqlite_master WHERE type='table' AND name='{DEFAULT_TABLE_NAME}'",
166164
),
167165
[],
168166
|row| row.get(0),
@@ -181,8 +179,7 @@ mod rusqlite {
181179
let table_name: String = conn
182180
.query_row(
183181
&format!(
184-
"SELECT name FROM sqlite_master WHERE type='table' AND name='{}'",
185-
DEFAULT_TABLE_NAME
182+
"SELECT name FROM sqlite_master WHERE type='table' AND name='{DEFAULT_TABLE_NAME}'",
186183
),
187184
[],
188185
|row| row.get(0),

refinery/tests/tiberius.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ mod tiberius {
292292

293293
let row = client
294294
.simple_query(&format!(
295-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
296-
DEFAULT_TABLE_NAME
295+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
297296
))
298297
.await
299298
.unwrap()
@@ -334,8 +333,7 @@ mod tiberius {
334333

335334
let row = client
336335
.simple_query(&format!(
337-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
338-
DEFAULT_TABLE_NAME
336+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
339337
))
340338
.await
341339
.unwrap()

refinery/tests/tokio_postgres.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ mod tokio_postgres {
156156
let rows = client
157157
.query(
158158
&format!(
159-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
160-
DEFAULT_TABLE_NAME
159+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
161160
),
162161
&[],
163162
)
@@ -193,8 +192,7 @@ mod tokio_postgres {
193192
let rows = client
194193
.query(
195194
&format!(
196-
"SELECT table_name FROM information_schema.tables WHERE table_name='{}'",
197-
DEFAULT_TABLE_NAME
195+
"SELECT table_name FROM information_schema.tables WHERE table_name='{DEFAULT_TABLE_NAME}'",
198196
),
199197
&[],
200198
)

refinery_core/src/config.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Config {
5252
pub fn from_env_var(name: &str) -> Result<Config, Error> {
5353
let value = std::env::var(name).map_err(|_| {
5454
Error::new(
55-
Kind::ConfigError(format!("Couldn't find {} environment variable", name)),
55+
Kind::ConfigError(format!("Couldn't find {name} environment variable")),
5656
None,
5757
)
5858
})?;
@@ -64,14 +64,14 @@ impl Config {
6464
pub fn from_file_location<T: AsRef<std::path::Path>>(location: T) -> Result<Config, Error> {
6565
let file = std::fs::read_to_string(&location).map_err(|err| {
6666
Error::new(
67-
Kind::ConfigError(format!("could not open config file, {}", err)),
67+
Kind::ConfigError(format!("could not open config file, {err}")),
6868
None,
6969
)
7070
})?;
7171

7272
let mut config: Config = toml::from_str(&file).map_err(|err| {
7373
Error::new(
74-
Kind::ConfigError(format!("could not parse config file, {}", err)),
74+
Kind::ConfigError(format!("could not parse config file, {err}")),
7575
None,
7676
)
7777
})?;
@@ -99,7 +99,7 @@ impl Config {
9999

100100
let config_db_path = config_db_path.canonicalize().map_err(|err| {
101101
Error::new(
102-
Kind::ConfigError(format!("invalid sqlite db path, {}", err)),
102+
Kind::ConfigError(format!("invalid sqlite db path, {err}")),
103103
None,
104104
)
105105
})?;
@@ -293,7 +293,7 @@ impl FromStr for Config {
293293
fn from_str(url_str: &str) -> Result<Config, Self::Err> {
294294
let url = Url::parse(url_str).map_err(|_| {
295295
Error::new(
296-
Kind::ConfigError(format!("Couldn't parse the string '{}' as a URL", url_str)),
296+
Kind::ConfigError(format!("Couldn't parse the string '{url_str}' as a URL")),
297297
None,
298298
)
299299
})?;
@@ -365,7 +365,7 @@ cfg_if::cfg_if! {
365365

366366
if let Some(port) = &config.main.db_port {
367367
let port = port.parse().map_err(|_| Error::new(
368-
Kind::ConfigError(format!("Couldn't parse value {} as mssql port", port)),
368+
Kind::ConfigError(format!("Couldn't parse value {port} as mssql port")),
369369
None,
370370
))?;
371371
tconfig.port(port);

refinery_core/src/drivers/tiberius.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,14 @@ where
8686
{
8787
fn assert_migrations_table_query(migration_table_name: &str) -> String {
8888
format!(
89-
"IF NOT EXISTS(SELECT 1 FROM sys.Tables WHERE Name = N'{table_name}')
89+
"IF NOT EXISTS(SELECT 1 FROM sys.Tables WHERE Name = N'{migration_table_name}')
9090
BEGIN
91-
CREATE TABLE {table_name}(
91+
CREATE TABLE {migration_table_name}(
9292
version INT PRIMARY KEY,
9393
name VARCHAR(255),
9494
applied_on VARCHAR(255),
9595
checksum VARCHAR(255));
96-
END",
97-
table_name = migration_table_name
96+
END"
9897
)
9998
}
10099
}

refinery_core/src/runner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl fmt::Display for Type {
2525
Type::Versioned => "V",
2626
Type::Unversioned => "U",
2727
};
28-
write!(f, "{}", version_type)
28+
write!(f, "{version_type}")
2929
}
3030
}
3131

@@ -35,7 +35,7 @@ impl fmt::Debug for Type {
3535
Type::Versioned => "Versioned",
3636
Type::Unversioned => "Unversioned",
3737
};
38-
write!(f, "{}", version_type)
38+
write!(f, "{version_type}")
3939
}
4040
}
4141

refinery_core/src/traits/async.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::error::WrapMigrationError;
22
use crate::traits::{
3-
insert_migration_query, verify_migrations, ASSERT_MIGRATIONS_TABLE_QUERY,
4-
GET_APPLIED_MIGRATIONS_QUERY, GET_LAST_APPLIED_MIGRATION_QUERY,
3+
insert_migration_query, verify_migrations, GET_APPLIED_MIGRATIONS_QUERY,
4+
GET_LAST_APPLIED_MIGRATION_QUERY,
55
};
66
use crate::{Error, Migration, Report, Target};
77

@@ -49,7 +49,7 @@ async fn migrate<T: AsyncTransaction>(
4949
])
5050
.await
5151
.migration_err(
52-
&format!("error applying migration {}", migration),
52+
&format!("error applying migration {migration}"),
5353
Some(&applied_migrations),
5454
)?;
5555
applied_migrations.push(migration);

0 commit comments

Comments
 (0)