summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Dague <sdague@linux.vnet.ibm.com>2013-01-16 08:04:45 -0500
committerSean Dague <sdague@linux.vnet.ibm.com>2013-01-16 18:41:54 -0500
commit6556b8650f11ceebe0c59fe88e6c6bdf65e439b5 (patch)
tree5d99fca658c9470047652245d491ef683d8c468b
parent01f204efdf4cee1823475fd346ce6dbaca915715 (diff)
downloadnova-6556b8650f11ceebe0c59fe88e6c6bdf65e439b5.tar.gz
nova-6556b8650f11ceebe0c59fe88e6c6bdf65e439b5.tar.xz
nova-6556b8650f11ceebe0c59fe88e6c6bdf65e439b5.zip
don't allow crs in the code
triggered by this slipping into quantum, now that we have more windows developers we should ensure that \r\n doesn't land in the code as a line ending. This check prevents it. Change-Id: I0a82be0e74915d3c3c25203db110d279580c148b
-rw-r--r--HACKING.rst1
-rwxr-xr-xtools/hacking.py13
2 files changed, 14 insertions, 0 deletions
diff --git a/HACKING.rst b/HACKING.rst
index be894f072..35493e55b 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -9,6 +9,7 @@ Nova Style Commandments
General
-------
- Put two newlines between top-level code (funcs, classes, etc)
+- Use only UNIX style newlines ("\n"), not Windows style ("\r\n")
- Put one newline between methods in classes and anywhere else
- Long lines should be wrapped in parentheses
in preference to using a backslash for line continuation.
diff --git a/tools/hacking.py b/tools/hacking.py
index ed22956eb..cfdd1b5b1 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -359,6 +359,19 @@ def nova_docstring_multiline_end(physical_line):
return (pos, "N403: multi line docstring end on new line")
+def nova_no_cr(physical_line):
+ r"""Check that we only use newlines not cariage returns.
+
+ Okay: import os\nimport sys
+ # pep8 doesn't yet replace \r in strings, will work on an
+ # upstream fix
+ N901 import os\r\nimport sys
+ """
+ pos = physical_line.find('\r')
+ if pos != -1 and pos == (len(physical_line) - 2):
+ return (pos, "N901: Windows style line endings not allowed in code")
+
+
FORMAT_RE = re.compile("%(?:"
"%|" # Ignore plain percents
"(\(\w+\))?" # mapping key