summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-02-01 01:52:26 +0000
committerGerrit Code Review <review@openstack.org>2013-02-01 01:52:26 +0000
commit7b95988c8bf87e8674fccab14d0e2a239e2384a6 (patch)
tree5e4a1da592f1e9904a0eed641e1da35f2b4ff321
parentf8d2021783889442f12ed1d3658097a91f2d1f53 (diff)
parent2cd46876836310d94df0bad58f967023db4c727a (diff)
downloadnova-7b95988c8bf87e8674fccab14d0e2a239e2384a6.tar.gz
nova-7b95988c8bf87e8674fccab14d0e2a239e2384a6.tar.xz
nova-7b95988c8bf87e8674fccab14d0e2a239e2384a6.zip
Merge "Add 'not in' test to tools/hacking.py"
-rwxr-xr-xtools/hacking.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/hacking.py b/tools/hacking.py
index 801a87899..42a644e7d 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -43,6 +43,7 @@ logging.disable('LOG')
#N6xx calling methods
#N7xx localization
#N8xx git commit messages
+#N9xx other
IMPORT_EXCEPTIONS = ['sqlalchemy', 'migrate', 'nova.db.sqlalchemy.session']
START_DOCSTRING_TRIPLE = ['u"""', 'r"""', '"""', "u'''", "r'''", "'''"]
@@ -493,6 +494,23 @@ def nova_localization_strings(logical_line, tokens):
#TODO(jogo) Dict and list objects
+
+def nova_not_in(logical_line):
+ r"""Check localization in line.
+
+ Okay: if x not in y
+ Okay: if not (X in Y or X is Z)
+ Okay: if not (X in Y)
+ N901: if not X in Y
+ N901: if not X.B in Y
+ """
+ split_line = logical_line.split()
+ if (len(split_line) == 5 and split_line[0] == 'if' and
+ split_line[1] == 'not' and split_line[3] == 'in' and not
+ split_line[2].startswith('(')):
+ yield (logical_line.find('not'), "N901: Use the 'not in' "
+ "operator for collection membership evaluation")
+
current_file = ""