aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy/tidy.py
diff options
context:
space:
mode:
authorZbynek Winkler <zbynek.winkler@gmail.com>2016-04-21 17:06:57 +0200
committerZbynek Winkler <zbynek.winkler@gmail.com>2016-04-21 17:52:09 +0200
commitb6b8ac6cd394a0ac6182c4c7aa5c500e10a6f214 (patch)
tree19a03971ad35e9718e13851eaa9f3c8afe9ed9fb /python/tidy/servo_tidy/tidy.py
parent45562287e608f60203686435558bb8a9a614f9be (diff)
downloadservo-b6b8ac6cd394a0ac6182c4c7aa5c500e10a6f214.tar.gz
servo-b6b8ac6cd394a0ac6182c4c7aa5c500e10a6f214.zip
tidy check for vim and emacs modelines.
See https://github.com/servo/servo/issues/10719.
Diffstat (limited to 'python/tidy/servo_tidy/tidy.py')
-rw-r--r--python/tidy/servo_tidy/tidy.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py
index 206346675e2..d90660ac238 100644
--- a/python/tidy/servo_tidy/tidy.py
+++ b/python/tidy/servo_tidy/tidy.py
@@ -133,6 +133,14 @@ def check_license(file_name, lines):
yield (1, "incorrect license")
+def check_modeline(file_name, lines):
+ for idx, line in enumerate(lines[:5]):
+ if re.search('^.*[ \t](vi:|vim:|ex:)[ \t]', line):
+ yield (idx + 1, "vi modeline present")
+ elif re.search('-\*-.*-\*-', line, re.IGNORECASE):
+ yield (idx + 1, "emacs file variables present")
+
+
def check_length(file_name, idx, line):
if file_name.endswith(".lock") or file_name.endswith(".json"):
raise StopIteration
@@ -638,7 +646,7 @@ def scan(faster=False, progress=True):
# standard checks
files_to_check = filter_files('.', faster, progress)
checking_functions = (check_flake8, check_lock, check_webidl_spec, check_json)
- line_checking_functions = (check_license, check_by_line, check_toml, check_rust, check_spec)
+ line_checking_functions = (check_license, check_by_line, check_toml, check_rust, check_spec, check_modeline)
errors = collect_errors_for_files(files_to_check, checking_functions, line_checking_functions)
# wpt lint checks
wpt_lint_errors = check_wpt_lint_errors(get_wpt_files(faster, progress))