summaryrefslogtreecommitdiffstats
path: root/tools/hacking.py
diff options
context:
space:
mode:
authorSean Dague <sdague@linux.vnet.ibm.com>2013-01-04 15:46:18 -0500
committerSean Dague <sdague@linux.vnet.ibm.com>2013-01-07 21:39:58 -0500
commit37bfdd3b38b2d2c2f088f67e7bcc2f26c6e01c1c (patch)
treef6a4d9354c3ea795fe5b270046a20fc6d21a12ca /tools/hacking.py
parent9279e0052f300eb0f64d63c970d34c050d744906 (diff)
downloadnova-37bfdd3b38b2d2c2f088f67e7bcc2f26c6e01c1c.tar.gz
nova-37bfdd3b38b2d2c2f088f67e7bcc2f26c6e01c1c.tar.xz
nova-37bfdd3b38b2d2c2f088f67e7bcc2f26c6e01c1c.zip
fix N401 errors, stop ignoring all N4* errors
We had previously been ignoring all our custom N4xx hacking.py errors. This fixes all the N401 errors "doc strings should not start with a space" and reduces the ignore set down to N402 only "single line docstrings should end with period". It also fixes the N401 parser to catch only docstrings, and not tripple quoted string blocks used later on in a function. Clean up a few of the more crazy uses of """ in our code Clean up additional funky comments to make indents a bit more consistent, and pull in lines when possible. Change-Id: I9040a1d2ca7efda83bd5e425b95d1408b5b63577
Diffstat (limited to 'tools/hacking.py')
-rwxr-xr-xtools/hacking.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/hacking.py b/tools/hacking.py
index bde4f42d4..a860aa37b 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -268,18 +268,23 @@ def nova_import_no_db_in_virt(logical_line, filename):
yield (0, "NOVA N307: nova.db import not allowed in nova/virt/*")
-def nova_docstring_start_space(physical_line):
+def nova_docstring_start_space(physical_line, previous_logical):
"""Check for docstring not start with space.
nova HACKING guide recommendation for docstring:
Docstring should not start with space
N401
"""
- pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start
- if (pos != -1 and len(physical_line) > pos + 1):
- if (physical_line[pos + 3] == ' '):
- return (pos, "NOVA N401: one line docstring should not start with"
- " a space")
+ # it's important that we determine this is actually a docstring,
+ # and not a doc block used somewhere after the first line of a
+ # function def
+ if (previous_logical.startswith("def ") or
+ previous_logical.startswith("class ")):
+ pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE])
+ if (pos != -1 and len(physical_line) > pos + 4):
+ if (physical_line[pos + 3] == ' '):
+ return (pos, "NOVA N401: docstring should not start with"
+ " a space")
def nova_docstring_one_line(physical_line):