aboutsummaryrefslogtreecommitdiff
path: root/crates/tools/src/lib.rs
diff options
context:
space:
mode:
authorAlan Du <[email protected]>2019-06-03 14:43:06 +0100
committerAlan Du <[email protected]>2019-06-04 01:34:00 +0100
commita181fd318b12d0648d126b81ed031d074c8471cf (patch)
tree8f4eb163d7ad51b756cf078630803d5c7f78560b /crates/tools/src/lib.rs
parentd1b9fa446a3dbfb216fcc0b07d8a2990c632df9c (diff)
Implement cargo lint to run clippy
Diffstat (limited to 'crates/tools/src/lib.rs')
-rw-r--r--crates/tools/src/lib.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs
index 11b52ccb7..92634655d 100644
--- a/crates/tools/src/lib.rs
+++ b/crates/tools/src/lib.rs
@@ -133,6 +133,34 @@ pub fn install_format_hook() -> Result<()> {
133 Ok(()) 133 Ok(())
134} 134}
135 135
136pub fn run_clippy() -> Result<()> {
137 match Command::new("rustup")
138 .args(&["run", TOOLCHAIN, "--", "cargo", "clippy", "--version"])
139 .stderr(Stdio::null())
140 .stdout(Stdio::null())
141 .status()
142 {
143 Ok(status) if status.success() => (),
144 _ => install_clippy()?,
145 };
146
147 let allowed_lints = ["clippy::collapsible_if", "clippy::nonminimal_bool"];
148 run(
149 &format!(
150 "rustup run {} -- cargo clippy --all-features --all-targets -- -A {}",
151 TOOLCHAIN,
152 allowed_lints.join(" -A ")
153 ),
154 ".",
155 )?;
156 Ok(())
157}
158
159pub fn install_clippy() -> Result<()> {
160 run(&format!("rustup install {}", TOOLCHAIN), ".")?;
161 run(&format!("rustup component add clippy --toolchain {}", TOOLCHAIN), ".")
162}
163
136pub fn run_fuzzer() -> Result<()> { 164pub fn run_fuzzer() -> Result<()> {
137 match Command::new("cargo") 165 match Command::new("cargo")
138 .args(&["fuzz", "--help"]) 166 .args(&["fuzz", "--help"])