Skip to content

Commit

Permalink
Put back tidy check on error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 27, 2019
1 parent 4eee955 commit 243fb6f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/error_codes_check.rs
Expand Up @@ -4,7 +4,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::fs::read_to_string; use std::fs::read_to_string;
use std::io::Read;
use std::path::Path; use std::path::Path;


// A few of those error codes can't be tested but all the others can and *should* be tested! // A few of those error codes can't be tested but all the others can and *should* be tested!
Expand Down
15 changes: 13 additions & 2 deletions src/tools/tidy/src/style.rs
Expand Up @@ -141,17 +141,28 @@ pub fn check(path: &Path, bad: &mut bool) {
super::walk(path, &mut super::filter_dirs, &mut |entry, contents| { super::walk(path, &mut super::filter_dirs, &mut |entry, contents| {
let file = entry.path(); let file = entry.path();
let filename = file.file_name().unwrap().to_string_lossy(); let filename = file.file_name().unwrap().to_string_lossy();
let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h"]; let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md"];
if extensions.iter().all(|e| !filename.ends_with(e)) || if extensions.iter().all(|e| !filename.ends_with(e)) ||
filename.starts_with(".#") { filename.starts_with(".#") {
return return
} }


if filename.ends_with(".md") &&
file.parent()
.unwrap()
.file_name()
.unwrap()
.to_string_lossy() != "error_codes" {
// We don't want to check all ".md" files (almost of of them aren't compliant
// currently), just the long error code explanation ones.
return;
}

if contents.is_empty() { if contents.is_empty() {
tidy_error!(bad, "{}: empty file", file.display()); tidy_error!(bad, "{}: empty file", file.display());
} }


let max_columns = if filename == "error_codes.rs" { let max_columns = if filename == "error_codes.rs" || filename.ends_with(".md") {
ERROR_CODE_COLS ERROR_CODE_COLS
} else { } else {
COLS COLS
Expand Down

0 comments on commit 243fb6f

Please sign in to comment.