]> git.lizzy.rs Git - rust.git/blobdiff - src/etc/tidy.py
cleanup: s/impl Copy/#[derive(Copy)]/g
[rust.git] / src / etc / tidy.py
index 6529b4d084e0afce5362eb0aa521b6dada478868..c65b762e5173168c880f18dc5209b99e62c65226 100644 (file)
@@ -8,7 +8,7 @@
 # option. This file may not be copied, modified, or distributed
 # except according to those terms.
 
-import sys, fileinput, subprocess, re
+import sys, fileinput, subprocess, re, os
 from licenseck import *
 import snapshot
 
@@ -58,19 +58,20 @@ try:
     for line in fileinput.input(file_names,
                                 openhook=fileinput.hook_encoded("utf-8")):
 
-        if fileinput.filename().find("tidy.py") == -1:
-            if line.find(cr_flag) != -1:
+        if "tidy.py" not in fileinput.filename():
+            if cr_flag in line:
                 check_cr = False
-            if line.find(tab_flag) != -1:
+            if tab_flag in line:
                 check_tab = False
-            if line.find(linelength_flag) != -1:
+            if linelength_flag in line:
                 check_linelength = False
-            if line.find("// XXX") != -1:
-                report_err("XXX is no longer necessary, use FIXME")
-            if line.find("TODO") != -1:
+            if "TODO" in line:
                 report_err("TODO is deprecated; use FIXME")
-            match = re.match(r'^.*//\s*(NOTE.*)$', line)
+            match = re.match(r'^.*/(\*|/!?)\s*XXX', line)
             if match:
+                report_err("XXX is no longer necessary, use FIXME")
+            match = re.match(r'^.*//\s*(NOTE.*)$', line)
+            if match and "TRAVIS" not in os.environ:
                 m = match.group(1)
                 if "snap" in m.lower():
                     report_warn(match.group(1))
@@ -85,10 +86,10 @@ try:
                 if "SNAP" in line:
                     report_warn("unmatched SNAP line: " + line)
 
-        if check_tab and (line.find('\t') != -1 and
-            fileinput.filename().find("Makefile") == -1):
+        if check_tab and ('\t' in line and
+            "Makefile" not in fileinput.filename()):
             report_err("tab character")
-        if check_cr and not autocrlf and line.find('\r') != -1:
+        if check_cr and not autocrlf and '\r' in line:
             report_err("CR character")
         if line.endswith(" \n") or line.endswith("\t\n"):
             report_err("trailing whitespace")
@@ -112,7 +113,7 @@ try:
     if current_name != "":
         do_license_check(current_name, current_contents)
 
-except UnicodeDecodeError, e:
+except UnicodeDecodeError as e:
     report_err("UTF-8 decoding error " + str(e))