summaryrefslogtreecommitdiffstats
path: root/xtask/src/clippy.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/clippy.rs')
-rw-r--r--xtask/src/clippy.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/xtask/src/clippy.rs b/xtask/src/clippy.rs
new file mode 100644
index 000000000..a19f8e5a5
--- /dev/null
+++ b/xtask/src/clippy.rs
@@ -0,0 +1,43 @@
+//! Handle running `cargo clippy` on the sources.
+use crate::{build, flags};
+use anyhow::Context;
+use std::path::{Path, PathBuf};
+use xshell::{cmd, Shell};
+
+pub fn clippy(sh: &Shell, _flags: flags::Clippy) -> anyhow::Result<()> {
+ let _pd = sh.push_dir(crate::project_root());
+
+ build::build(
+ sh,
+ flags::Build {
+ release: false,
+ no_plugins: false,
+ plugins_only: true,
+ },
+ )
+ .context("failed to run task 'clippy'")?;
+
+ let cargo = check_clippy()
+ .and_then(|_| crate::cargo())
+ .context("failed to run task 'clippy'")?;
+
+ for subcrate in crate::WORKSPACE_MEMBERS.iter() {
+ let _pd = sh.push_dir(Path::new(subcrate));
+ // Tell the user where we are now
+ println!();
+ let msg = format!(">> Running clippy on '{subcrate}'");
+ crate::status(&msg);
+ println!("{}", msg);
+
+ cmd!(sh, "{cargo} clippy --all-targets --all-features")
+ .run()
+ .with_context(|| format!("failed to run task 'clippy' on '{subcrate}'"))?;
+ }
+ Ok(())
+}
+
+fn check_clippy() -> anyhow::Result<PathBuf> {
+ which::which("cargo-clippy").context(
+ "Couldn't find 'clippy' executable. Please install it with `rustup component add clippy`",
+ )
+}