From: Ian Jackson Date: Thu, 31 Mar 2022 19:25:30 +0000 (+0100) Subject: clippy: Miscellaneous minor changes, and allow lints X-Git-Tag: otter-1.0.0~30 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=667252d20536a57ed8d4b4633699917a381df827;p=otter.git clippy: Miscellaneous minor changes, and allow lints Signed-off-by: Ian Jackson --- diff --git a/cli/clisupport.rs b/cli/clisupport.rs index e405f632..fd54f27a 100644 --- a/cli/clisupport.rs +++ b/cli/clisupport.rs @@ -63,7 +63,7 @@ pub fn default_ssh_proxy_command() -> String { impl MainOpts { pub fn game(&self) -> &str { - self.game.as_ref().map(|s| s.as_str()).unwrap_or_else(||{ + self.game.as_deref().unwrap_or_else(||{ eprintln!( "game (table) name not specified; pass --game option"); exit(EXIT_USAGE); @@ -71,7 +71,7 @@ impl MainOpts { } pub fn instance(&self) -> InstanceName { - match self.game().strip_prefix(":") { + match self.game().strip_prefix(':') { Some(rest) => { InstanceName { account: self.account.clone(), @@ -422,7 +422,7 @@ pub fn setup_table(_ma: &MainOpts, instance_name: &InstanceName, spec: &TableSpe -> Vec { let TableSpec { players, player_perms, acl, links } = spec; let mut player_perms = player_perms.clone() - .unwrap_or(PLAYER_DEFAULT_PERMS.iter().cloned().collect()); + .unwrap_or_else(|| PLAYER_DEFAULT_PERMS.iter().cloned().collect()); player_perms.extend(PLAYER_ALWAYS_PERMS.iter()); let acl: RawAcl<_> = diff --git a/clippy-options b/clippy-options index cdc6fc00..b4cfc50f 100644 --- a/clippy-options +++ b/clippy-options @@ -36,3 +36,4 @@ -A clippy::manual_map -A clippy::vec_init_then_push -A clippy::collapsible_if +-A clippy::iter_nth_zero diff --git a/jstest/jst-lower.rs b/jstest/jst-lower.rs index 610c156f..b44d611e 100644 --- a/jstest/jst-lower.rs +++ b/jstest/jst-lower.rs @@ -4,6 +4,9 @@ // OTTER_JST_LOWER_ONLY=exhaustive-05 +#![allow(clippy::or_fun_call)] +#![allow(clippy::unnecessary_operation)] // trips on #[throws(Explode)] + use otter_nodejs_tests::*; pub type Vpid = VisiblePieceId; @@ -167,7 +170,7 @@ impl Test { id, new_z, old_z, updated, heavy: start.heavy(), target: self.targets.contains(&id), - zupd: start.zupd.into(), + zupd: start.zupd, } }).collect_vec(); @@ -188,8 +191,8 @@ impl Test { p.zupd.show(), zl.show()); }; - pr(o, &o.old_z); print!(" "); - pr(n, &n.new_z); println!(""); + pr(o, o.old_z); print!(" "); + pr(n, n.new_z); println!(""); } // light targets are in same stacking order as before @@ -518,7 +521,7 @@ fn main() { tests.finish()?; } -static TEMPLATE: &'static str = r#" +static TEMPLATE: &str = r#" console.log('-------------------- {{ name }} --------------------') jstest_did = fs.openSync('{{ name }}.did', 'w'); diff --git a/jstest/jstest.rs b/jstest/jstest.rs index fdc46010..b352cc15 100644 --- a/jstest/jstest.rs +++ b/jstest/jstest.rs @@ -2,6 +2,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later // There is NO WARRANTY. +#![allow(clippy::or_fun_call)] +#![allow(clippy::unnecessary_operation)] // trips on #[throws(Explode)] + pub use otter::imports::*; pub use otter::prelude::*; diff --git a/wdriver/wdriver.rs b/wdriver/wdriver.rs index ae5781d3..1f8a3ffc 100644 --- a/wdriver/wdriver.rs +++ b/wdriver/wdriver.rs @@ -2,6 +2,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later // There is NO WARRANTY. +#![allow(clippy::or_fun_call)] +#![allow(clippy::unnecessary_operation)] // trips on #[throws(Explode)] + pub use otter_api_tests::*; pub use otter_api_tests as apitest; @@ -149,16 +152,16 @@ fn prepare_thirtyfour(ds: &DirSubst) ].iter().cloned().collect(); caps.add("prefs", prefs)?; caps.add("stdio", "inherit")?; - let mut driver = t4::WebDriver::new("http://localhost:4444", &caps) + let driver = t4::WebDriver::new("http://localhost:4444", &caps) .context("create 34 WebDriver")?; const FRONT: &str = "front"; - let mut js_logfile = JsLogfileImp::open(&ds, FRONT)?; + let mut js_logfile = JsLogfileImp::open(ds, FRONT)?; driver.set_window_name(FRONT).context("set initial window name")?; - screenshot(&mut driver, &mut count, "startup", log::Level::Trace)?; + screenshot(&driver, &mut count, "startup", log::Level::Trace)?; driver.get(URL).context("navigate to front page")?; - screenshot(&mut driver, &mut count, "front", log::Level::Trace)?; + screenshot(&driver, &mut count, "front", log::Level::Trace)?; js_logfile.fetch(&driver)?; let js_logs = vec![Rc::new(RefCell::new(js_logfile))]; @@ -346,8 +349,7 @@ impl<'g> WindowGuard<'g> { let elemid = format!("use{}", &pieceid); let elem = self.su.driver.find_element(By::Id(&elemid))?; PieceElement { - elem, - pieceid: pieceid.clone(), + elem, pieceid, w: self, } } @@ -458,7 +460,7 @@ impl<'g> WindowGuard<'g> { dbg!(log) } - inner(&self, &mut move |s| ignore_before.matches(s))? + inner(self, &mut move |s| ignore_before.matches(s))? } #[throws(AE)]