diff options
author | Hugo Thiessard <hugo.thiessard@etu.u-bordeaux.fr> | 2015-08-30 18:49:50 +0200 |
---|---|---|
committer | Hugo Thiessard <hugo.thiessard@etu.u-bordeaux.fr> | 2015-09-18 21:32:00 +0200 |
commit | e81e91207cb87ade4eeaa99917eaecd0f5ecd00d (patch) | |
tree | de93fa53a039689b648bce5d054ce39508ca2a79 /python/tidy.py | |
parent | 9b939546a660fb24985e54aba1c2c47d1cf057a4 (diff) | |
download | servo-e81e91207cb87ade4eeaa99917eaecd0f5ecd00d.tar.gz servo-e81e91207cb87ade4eeaa99917eaecd0f5ecd00d.zip |
fixes #7390 : tidy now check the order of mod declarations even whith attribute
Diffstat (limited to 'python/tidy.py')
-rw-r--r-- | python/tidy.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/python/tidy.py b/python/tidy.py index d637c9178f6..12057d665d8 100644 --- a/python/tidy.py +++ b/python/tidy.py @@ -203,6 +203,8 @@ def check_rust(file_name, contents): uses = [] + mods = [] + for idx, line in enumerate(contents): # simplify the analysis line = line.strip() @@ -305,6 +307,29 @@ def check_rust(file_name, contents): yield (idx + 1 - len(uses) + i, message + expected + found) uses = [] + # modules must be in the same line and alphabetically sorted + if line.startswith("mod ") or line.startswith("pub mod "): + mod = "" + if line.startswith("mod "): + mod = line[4:] + else: + mod = line[8:] + + match = line.find(" {") + if match == -1: + if not mod.endswith(";"): + yield (idx + 1, "mod statement spans multiple lines") + mods.append(mod[:len(mod) - 1]) + elif len(mods) > 0: + sorted_mods = sorted(mods) + for i in range(len(mods)): + if sorted_mods[i] != mods[i]: + message = "mod statement is not in alphabetical order" + expected = "\n\t\033[93mexpected: {}\033[0m".format(sorted_mods[i]) + found = "\n\t\033[91mfound: {}\033[0m".format(mods[i]) + yield (idx + 1 - len(mods) + i, message + expected + found) + mods = [] + # Avoid flagging <Item=Foo> constructs def is_associated_type(match, line, index): |