cargo clippy --fix

This switches to inlining variable names into format args. clippy
now suggests this syntax, and I like it.
This commit is contained in:
Scott Lamb
2023-01-29 15:01:19 -08:00
parent 159e426943
commit a9430464b6
31 changed files with 119 additions and 162 deletions

View File

@@ -35,7 +35,7 @@ pub struct Args<'a> {
fn set_journal_mode(conn: &rusqlite::Connection, requested: &str) -> Result<(), Error> {
assert!(!requested.contains(';')); // quick check for accidental sql injection.
let actual = conn.query_row(
&format!("pragma journal_mode = {}", requested),
&format!("pragma journal_mode = {requested}"),
params![],
|row| row.get::<_, String>(0),
)?;
@@ -191,12 +191,12 @@ mod tests {
let fresh = new_conn()?;
fresh.execute_batch(fresh_sql)?;
if let Some(diffs) = compare::get_diffs(
&format!("upgraded to version {}", ver),
&c,
&format!("fresh version {}", ver),
&format!("upgraded to version {ver}"),
c,
&format!("fresh version {ver}"),
&fresh,
)? {
panic!("Version {}: differences found:\n{}", ver, diffs);
panic!("Version {ver}: differences found:\n{diffs}");
}
Ok(())
}
@@ -284,14 +284,14 @@ mod tests {
] {
upgrade(
&Args {
sample_file_dir: Some(&tmpdir.path()),
sample_file_dir: Some(tmpdir.path()),
preset_journal: "delete",
no_vacuum: false,
},
*ver,
&mut upgraded,
)
.context(format!("upgrading to version {}", ver))?;
.context(format!("upgrading to version {ver}"))?;
if let Some(f) = fresh_sql {
compare(&upgraded, *ver, f)?;
}

View File

@@ -419,7 +419,6 @@ fn rfc6381_codec_from_sample_entry(sample_entry: &[u8]) -> Result<String, Error>
let constraint_flags_byte = sample_entry[104];
let level_idc = sample_entry[105];
Ok(format!(
"avc1.{:02x}{:02x}{:02x}",
profile_idc, constraint_flags_byte, level_idc
"avc1.{profile_idc:02x}{constraint_flags_byte:02x}{level_idc:02x}"
))
}

View File

@@ -149,7 +149,7 @@ pub fn run(_args: &super::Args, tx: &rusqlite::Transaction) -> Result<(), Error>
let dir = dir::Fd::open(path, false)?;
dir.lock(FlockArg::LockExclusiveNonblock)
.map_err(|e| e.context(format!("unable to lock dir {}", path)))?;
.map_err(|e| e.context(format!("unable to lock dir {path}")))?;
let mut need_sync = maybe_upgrade_meta(&dir, &db_meta)?;
if maybe_cleanup_garbage_uuids(&dir)? {

View File

@@ -268,7 +268,7 @@ pub fn run(_args: &super::Args, tx: &rusqlite::Transaction) -> Result<(), Error>
":video_sync_samples": video_sync_samples,
":video_sample_entry_id": video_sample_entry_id,
})
.with_context(|_| format!("Unable to insert composite_id {}", composite_id))?;
.with_context(|_| format!("Unable to insert composite_id {composite_id}"))?;
cum_duration_90k += i64::from(wall_duration_90k);
cum_runs += if run_offset == 0 { 1 } else { 0 };
}

View File

@@ -259,7 +259,7 @@ fn copy_cameras(tx: &rusqlite::Transaction) -> Result<(), Error> {
// of using a SQL NULL, so convert empty to None here.
// https://github.com/scottlamb/moonfire-nvr/issues/182
.filter(|h| !h.is_empty())
.map(|h| Url::parse(&format!("http://{}/", h)))
.map(|h| Url::parse(&format!("http://{h}/")))
.transpose()
.with_context(|_| "bad onvif_host")?,
username: username.take().unwrap_or_default(),