aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/tidy.py')
-rw-r--r--python/tidy.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/python/tidy.py b/python/tidy.py
index 659cf01b6d0..7a2993cdb6d 100644
--- a/python/tidy.py
+++ b/python/tidy.py
@@ -230,12 +230,25 @@ def check_rust(file_name, contents):
whitespace = False
uses = []
-
+ prev_crate = {}
mods = []
- for idx, line in enumerate(contents):
+ for idx, original_line in enumerate(contents):
# simplify the analysis
- line = line.strip()
+ line = original_line.strip()
+
+ # check extern crates
+ if line.startswith("extern crate"):
+ crate_name = line.replace("extern crate ", "").replace(";", "")
+ indent = len(original_line) - len(line)
+ if indent not in prev_crate:
+ prev_crate[indent] = ""
+ if prev_crate[indent] > crate_name:
+ message = "extern crate statement is not in alphabetical order"
+ expected = "\n\t\033[93mexpected: {}\033[0m".format(prev_crate[indent])
+ found = "\n\t\033[91mfound: {}\033[0m".format(crate_name)
+ yield(idx + 1, message + expected + found)
+ prev_crate[indent] = crate_name
# Simple heuristic to avoid common case of no comments.
if '/' in line:
@@ -540,6 +553,16 @@ def check_reftest_html_files_in_basic_list(reftest_dir):
yield (file_path, "", "not found in basic.list")
+def check_wpt_lint_errors():
+ import subprocess
+ wpt_working_dir = os.path.abspath(os.path.join(".", "tests", "wpt", "web-platform-tests"))
+ lint_cmd = os.path.join(wpt_working_dir, "lint")
+ try:
+ subprocess.check_call(lint_cmd, cwd=wpt_working_dir) # Must run from wpt's working dir
+ except subprocess.CalledProcessError as e:
+ yield ("WPT Lint Tool", "", "lint error(s) in Web Platform Tests: exit status {0}".format(e.returncode))
+
+
def scan():
all_files = (os.path.join(r, f) for r, _, files in os.walk(".") for f in files)
files_to_check = filter(should_check, all_files)
@@ -552,9 +575,9 @@ def scan():
reftest_to_check = filter(should_check_reftest, reftest_files)
r_errors = check_reftest_order(reftest_to_check)
not_found_in_basic_list_errors = check_reftest_html_files_in_basic_list(reftest_dir)
+ wpt_lint_errors = check_wpt_lint_errors()
- errors = list(itertools.chain(errors, r_errors, not_found_in_basic_list_errors))
-
+ errors = list(itertools.chain(errors, r_errors, not_found_in_basic_list_errors, wpt_lint_errors))
if errors:
for error in errors:
print "\033[94m{}\033[0m:\033[93m{}\033[0m: \033[91m{}\033[0m".format(*error)