aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2020-12-28 03:27:54 +0000
committerEdwin Cheng <[email protected]>2021-01-08 09:38:43 +0000
commit8584d269262e73aa7c3ebe25b1d61483375de267 (patch)
tree84fe69d32b6324efb7cd8743ba1d94fbe47fcf84 /xtask
parent66b132b4b21fb7034c698c22a9ca43e6b63ebd2f (diff)
Add check for dbg! macro
Diffstat (limited to 'xtask')
-rw-r--r--xtask/tests/tidy.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index e3572424b..a957e36af 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -85,6 +85,7 @@ fn rust_files_are_tidy() {
85 for path in rust_files(&project_root().join("crates")) { 85 for path in rust_files(&project_root().join("crates")) {
86 let text = read_file(&path).unwrap(); 86 let text = read_file(&path).unwrap();
87 check_todo(&path, &text); 87 check_todo(&path, &text);
88 check_dbg(&path, &text);
88 check_trailing_ws(&path, &text); 89 check_trailing_ws(&path, &text);
89 deny_clippy(&path, &text); 90 deny_clippy(&path, &text);
90 tidy_docs.visit(&path, &text); 91 tidy_docs.visit(&path, &text);
@@ -223,7 +224,7 @@ Zlib OR Apache-2.0 OR MIT
223fn check_todo(path: &Path, text: &str) { 224fn check_todo(path: &Path, text: &str) {
224 let need_todo = &[ 225 let need_todo = &[
225 // This file itself obviously needs to use todo (<- like this!). 226 // This file itself obviously needs to use todo (<- like this!).
226 "tests/cli.rs", 227 "tests/tidy.rs",
227 // Some of our assists generate `todo!()`. 228 // Some of our assists generate `todo!()`.
228 "handlers/add_turbo_fish.rs", 229 "handlers/add_turbo_fish.rs",
229 "handlers/generate_function.rs", 230 "handlers/generate_function.rs",
@@ -251,6 +252,32 @@ fn check_todo(path: &Path, text: &str) {
251 } 252 }
252} 253}
253 254
255fn check_dbg(path: &Path, text: &str) {
256 let need_dbg = &[
257 // This file itself obviously needs to use dbg.
258 "tests/tidy.rs",
259 // Assists to remove `dbg!()`
260 "handlers/remove_dbg.rs",
261 // We have .dbg postfix
262 "completion/src/completions/postfix.rs",
263 // The documentation in string literals may contain anything for its own purposes
264 "completion/src/lib.rs",
265 "completion/src/generated_lint_completions.rs",
266 // test for doc test for remove_dbg
267 "src/tests/generated.rs",
268 ];
269 if need_dbg.iter().any(|p| path.ends_with(p)) {
270 return;
271 }
272 if text.contains("dbg!") {
273 panic!(
274 "\ndbg! macros should not be committed to the master branch,\n\
275 {}\n",
276 path.display(),
277 )
278 }
279}
280
254fn check_trailing_ws(path: &Path, text: &str) { 281fn check_trailing_ws(path: &Path, text: &str) {
255 if is_exclude_dir(path, &["test_data"]) { 282 if is_exclude_dir(path, &["test_data"]) {
256 return; 283 return;