Skip to content

Commit 1347fb3

Browse files
rob-pclaude
andcommitted
style: clear the pre-existing clippy warnings
`cargo clippy --all-targets -- -D warnings` now passes. Mechanical, with no behaviour change: - four `match check_version_constraints(..) { Ok(v) => info!(..), Err(e) => return Err(e) }` blocks collapsed to `?` plus the log line - redundant `&` in format!/bail!/panic!/assert! arguments - `for (_k, v) in map.iter()` -> `map.values()` - `sort_by(|a, b| a.step.cmp(&b.step))` -> `sort_by_key(|c| c.step)`; both are stable sorts on the same key - a needless borrow at the af_anndata call site The one exception is `mutable_key_type` in jrsonnet_main, which fires on the map returned by jrsonnet's `tla_opts()`. The key type is theirs, not ours, and nothing here mutates a key, so that one is allowed with a note rather than worked around. Note for anyone doing this in bulk: `&x` is only redundant inside format-like macros. Removing it blindly turns `chem_hm.get(&name)` into a type error and `.args(&args)` into a move, both of which surfaced here and are restored. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VhyNvEWUgY8ALVacdJHxVJ
1 parent 78772e3 commit 1347fb3

8 files changed

Lines changed: 33 additions & 38 deletions

File tree

src/atac/index.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ pub(crate) fn piscem_index(af_home_path: &Path, opts: &IndexOpts) -> anyhow::Res
1717
.as_ref()
1818
.context("piscem program info is missing; please run `simpleaf set-paths`.")?;
1919

20-
match prog_utils::check_version_constraints(
20+
let af_ver = prog_utils::check_version_constraints(
2121
"piscem",
2222
prog_utils::min_versions::PISCEM,
2323
&piscem_prog_info.version,
24-
) {
25-
Ok(af_ver) => info!("found piscem version {:#}, proceeding", af_ver),
26-
Err(e) => return Err(e),
27-
}
24+
)?;
25+
info!("found piscem version {:#}, proceeding", af_ver);
2826

2927
let output = opts.output.clone();
3028
let output_index_dir = output.join("index");

src/atac/process.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -167,28 +167,24 @@ pub(crate) fn check_progs<P: AsRef<Path>>(
167167
.as_ref()
168168
.context("alevin-fry program info is missing; please run `simpleaf set-paths`.")?;
169169

170-
match prog_utils::check_version_constraints(
170+
let af_ver = prog_utils::check_version_constraints(
171171
"alevin-fry",
172172
prog_utils::min_versions::ALEVIN_FRY,
173173
&af_prog_info.version,
174-
) {
175-
Ok(af_ver) => info!("found alevin-fry version {:#}, proceeding", af_ver),
176-
Err(e) => return Err(e),
177-
}
174+
)?;
175+
info!("found alevin-fry version {:#}, proceeding", af_ver);
178176

179177
let piscem_prog_info = rp
180178
.piscem
181179
.as_ref()
182180
.context("piscem program info is missing; please run `simpleaf set-paths`.")?;
183181

184-
match prog_utils::check_version_constraints(
182+
let piscem_ver = prog_utils::check_version_constraints(
185183
"piscem",
186184
prog_utils::min_versions::PISCEM,
187185
&piscem_prog_info.version,
188-
) {
189-
Ok(piscem_ver) => info!("found piscem version {:#}, proceeding", piscem_ver),
190-
Err(e) => return Err(e),
191-
}
186+
)?;
187+
info!("found piscem version {:#}, proceeding", piscem_ver);
192188

193189
if opts.call_peaks {
194190
let macs_prog_info = rp
@@ -197,14 +193,12 @@ pub(crate) fn check_progs<P: AsRef<Path>>(
197193
.context(
198194
"macs3 program info is missing; please run `simpleaf set-paths` before using `--call-peaks`.",
199195
)?;
200-
match prog_utils::check_version_constraints(
196+
let macs_ver = prog_utils::check_version_constraints(
201197
"macs3",
202198
prog_utils::min_versions::MACS3,
203199
&macs_prog_info.version,
204-
) {
205-
Ok(macs_ver) => info!("found macs3 version {:#}, proceeding", macs_ver),
206-
Err(e) => return Err(e),
207-
}
200+
)?;
201+
info!("found macs3 version {:#}, proceeding", macs_ver);
208202
}
209203

210204
Ok(())
@@ -225,7 +219,7 @@ pub(crate) fn map_reads(af_home_path: &Path, opts: &ProcessOpts) -> anyhow::Resu
225219

226220
// using a piscem index
227221
let mut piscem_map_cmd =
228-
std::process::Command::new(format!("{}", &piscem_prog_info.exe_path.display()));
222+
std::process::Command::new(format!("{}", piscem_prog_info.exe_path.display()));
229223
let index_path = format!("{}", index_base.display());
230224
piscem_map_cmd
231225
.arg("map-sc-atac")
@@ -305,8 +299,7 @@ fn macs_call_peaks(af_home_path: &Path, opts: &ProcessOpts) -> anyhow::Result<Ma
305299
let bedsuf = if opts.compress { ".bed.gz" } else { ".bed" };
306300
let bed_input = gpl_dir.join(format!("map{}", bedsuf));
307301
let peaks_output = gpl_dir.join("macs");
308-
let mut macs_cmd =
309-
std::process::Command::new(format!("{}", &macs_prog_info.exe_path.display()));
302+
let mut macs_cmd = std::process::Command::new(format!("{}", macs_prog_info.exe_path.display()));
310303
macs_cmd
311304
.arg("callpeak")
312305
.arg("-f")
@@ -387,7 +380,7 @@ fn af_sort(af_home_path: &Path, opts: &ProcessOpts) -> anyhow::Result<SortStageO
387380

388381
let gpl_dir = opts.output.join("af_process");
389382
let rad_dir = opts.output.join("af_map");
390-
let mut af_sort = std::process::Command::new(format!("{}", &af_prog_info.exe_path.display()));
383+
let mut af_sort = std::process::Command::new(format!("{}", af_prog_info.exe_path.display()));
391384
af_sort
392385
.arg("atac")
393386
.arg("sort")
@@ -559,7 +552,7 @@ fn af_gpl(af_home_path: &Path, opts: &ProcessOpts) -> anyhow::Result<GplStageOut
559552
};
560553

561554
let map_file = opts.output.join("af_map");
562-
let mut af_gpl = std::process::Command::new(format!("{}", &af_prog_info.exe_path.display()));
555+
let mut af_gpl = std::process::Command::new(format!("{}", af_prog_info.exe_path.display()));
563556
af_gpl
564557
.arg("atac")
565558
.arg("generate-permit-list")

src/simpleaf_commands/chemistry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn get_chem_def_from_json(
159159
} else {
160160
bail!(
161161
"Could not find chemistry definition for {} from the requested JSON {}",
162-
&add_opts.name,
162+
add_opts.name,
163163
json_src
164164
);
165165
}
@@ -172,7 +172,7 @@ fn get_chem_def_from_json(
172172
} else {
173173
bail!(
174174
"Could not properly parse the chemistry {} from the requested source JSON {}",
175-
&add_opts.name,
175+
add_opts.name,
176176
json_src
177177
);
178178
}

src/simpleaf_commands/multiplex_quant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ pub fn multiplex_map_and_quant(af_home: &Path, opts: MultiplexQuantOpts) -> anyh
532532
let opath = anndata_path
533533
.as_ref()
534534
.expect("anndata_path must exist when --anndata-out is set");
535-
af_anndata::convert_csr_to_anndata(&quant_output, &opath)?;
535+
af_anndata::convert_csr_to_anndata(&quant_output, opath)?;
536536
convert_duration_secs = Some(convert_start.elapsed().as_secs_f64());
537537
}
538538

src/simpleaf_commands/quant.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ fn run_mapping_stage(
410410
"A piscem index is being used, but piscem program info is missing.",
411411
)?;
412412
let mut piscem_quant_cmd =
413-
std::process::Command::new(format!("{}", &piscem_prog_info.exe_path.display()));
413+
std::process::Command::new(format!("{}", piscem_prog_info.exe_path.display()));
414414
let index_path = format!("{}", index_base.display());
415415
piscem_quant_cmd
416416
.arg("map-sc")
@@ -514,7 +514,7 @@ fn run_quant_stage(
514514
.context("Alevin-fry program info is missing; please run `simpleaf set-paths`.")?
515515
.exe_path
516516
.clone();
517-
let mut alevin_gpl_cmd = std::process::Command::new(format!("{}", &alevin_fry.display()));
517+
let mut alevin_gpl_cmd = std::process::Command::new(format!("{}", alevin_fry.display()));
518518
let gpl_threads = setup.threads.min(8);
519519
alevin_gpl_cmd.arg("generate-permit-list");
520520
alevin_gpl_cmd.arg("-i").arg(&mapping.map_output);
@@ -530,7 +530,7 @@ fn run_quant_stage(
530530
exec::run_checked(&mut alevin_gpl_cmd, "[generate permit list]")?;
531531
let gpl_duration = gpl_start.elapsed();
532532

533-
let mut alevin_collate_cmd = std::process::Command::new(format!("{}", &alevin_fry.display()));
533+
let mut alevin_collate_cmd = std::process::Command::new(format!("{}", alevin_fry.display()));
534534
alevin_collate_cmd.arg("collate");
535535
alevin_collate_cmd.arg("-i").arg(&gpl_output);
536536
alevin_collate_cmd.arg("-r").arg(&mapping.map_output);
@@ -545,7 +545,7 @@ fn run_quant_stage(
545545
exec::run_checked(&mut alevin_collate_cmd, "[collate]")?;
546546
let collate_duration = collate_start.elapsed();
547547

548-
let mut alevin_quant_cmd = std::process::Command::new(format!("{}", &alevin_fry.display()));
548+
let mut alevin_quant_cmd = std::process::Command::new(format!("{}", alevin_fry.display()));
549549
alevin_quant_cmd
550550
.arg("quant")
551551
.arg("-i")

src/utils/jrsonnet_main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ fn main_catch(opts: Opts) -> anyhow::Result<String> {
210210
}
211211
}
212212

213+
// `tla_opts()` hands back a jrsonnet map whose key type carries interior
214+
// mutability. The key is never mutated here -- and the type is jrsonnet's,
215+
// not ours to change -- so the lint has nothing to catch.
216+
#[allow(clippy::mutable_key_type)]
213217
fn main_real(opts: Opts) -> Result<String, Error> {
214218
let _gc_leak_guard = opts.gc.leak_on_exit();
215219
let _gc_print_stats = opts.gc.stats_printer();

src/utils/workflow_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ be certain you intend to do this.",
196196
// remain that we have not seen, print out the appropriate
197197
// warning (or error) message. If the message is an error, then
198198
// bail after issuing it.
199-
for (_cn, action) in expected_columns.iter() {
199+
for action in expected_columns.values() {
200200
match action {
201201
HeaderFieldAction::Recommended(msg) => {
202202
warn!("{}", msg);
@@ -780,7 +780,7 @@ impl SimpleafWorkflow {
780780
)?;
781781

782782
// sort the cmd queue by its `step`.
783-
cmd_queue.sort_by(|cmd1, cmd2| cmd1.step.cmp(&cmd2.step));
783+
cmd_queue.sort_by_key(|cmd| cmd.step);
784784

785785
Ok(SimpleafWorkflow {
786786
af_home_path: af_home_path.as_ref().to_owned(),
@@ -1448,7 +1448,7 @@ pub fn parse_manifest<T: AsRef<Path>>(manifest_path: &T) -> anyhow::Result<serde
14481448
// Open the file in read-only mode with buffer.
14491449
let manifest_path = manifest_path.as_ref();
14501450
let file = File::open(manifest_path)
1451-
.with_context(|| format!("couldn't open manifest path {}", &manifest_path.display()))?;
1451+
.with_context(|| format!("couldn't open manifest path {}", manifest_path.display()))?;
14521452
let reader = BufReader::new(file);
14531453
let manifest = serde_json::from_reader(reader)?;
14541454
Ok(manifest)
@@ -1836,7 +1836,7 @@ mod tests {
18361836
} else {
18371837
panic!(
18381838
"Expected {:?} to match WFCommand::ExternalCommand, but it didn't",
1839-
&cmd.cmd
1839+
cmd.cmd
18401840
);
18411841
}
18421842

tests/cli_help_snapshots.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn cli_help_outputs_match_snapshots() {
115115
assert!(
116116
output.status.success(),
117117
"expected success for args {:?}, got status {:?}\nstderr:\n{}",
118-
&args,
118+
args,
119119
output.status.code(),
120120
String::from_utf8_lossy(&output.stderr)
121121
);
@@ -139,7 +139,7 @@ fn cli_help_outputs_match_snapshots() {
139139
"help output drifted for args {:?} against snapshot {}.\n\
140140
If this change is intended, regenerate with:\n \
141141
UPDATE_CLI_SNAPSHOTS=1 cargo test --test cli_help_snapshots",
142-
&args, snapshot_file
142+
args, snapshot_file
143143
);
144144
}
145145

0 commit comments

Comments
 (0)