summaryrefslogtreecommitdiff
path: root/saharaclient/tests/hacking/checks.py
diff options
context:
space:
mode:
Diffstat (limited to 'saharaclient/tests/hacking/checks.py')
-rw-r--r--saharaclient/tests/hacking/checks.py30
1 files changed, 9 insertions, 21 deletions
diff --git a/saharaclient/tests/hacking/checks.py b/saharaclient/tests/hacking/checks.py
index 23d0019..bbb249a 100644
--- a/saharaclient/tests/hacking/checks.py
+++ b/saharaclient/tests/hacking/checks.py
@@ -16,11 +16,8 @@
import re
import tokenize
-import pep8
-
-from saharaclient.tests.hacking import commit_message
-from saharaclient.tests.hacking import import_checks
-from saharaclient.tests.hacking import logging_checks
+from hacking import core
+import pycodestyle
RE_OSLO_IMPORTS = (re.compile(r"(((from)|(import))\s+oslo\.)"),
re.compile(r"(from\s+oslo\s+import)"))
@@ -44,6 +41,7 @@ def _any_in(line, *sublines):
return False
+@core.flake8ext
def import_db_only_in_conductor(logical_line, filename):
"""Check that db calls are only in conductor module and in tests.
@@ -63,6 +61,7 @@ def import_db_only_in_conductor(logical_line, filename):
"sahara/conductor/*")
+@core.flake8ext
def hacking_no_author_attr(logical_line, tokens):
"""__author__ should not be used.
@@ -74,6 +73,7 @@ def hacking_no_author_attr(logical_line, tokens):
"S362: __author__ should not be used")
+@core.flake8ext
def check_oslo_namespace_imports(logical_line):
"""Check to prevent old oslo namespace usage.
@@ -90,6 +90,7 @@ def check_oslo_namespace_imports(logical_line):
logical_line))
+@core.flake8ext
def dict_constructor_with_list_copy(logical_line):
"""Check to prevent dict constructor with a sequence of key-value pairs.
@@ -100,12 +101,13 @@ def dict_constructor_with_list_copy(logical_line):
'constructor with a sequence of key-value pairs.')
+@core.flake8ext
def use_jsonutils(logical_line, filename):
"""Check to prevent importing json in sahara code.
S375
"""
- if pep8.noqa(logical_line):
+ if pycodestyle.noqa(logical_line):
return
if (RE_USE_JSONUTILS_INVALID_LINE.match(logical_line) and
not RE_USE_JSONUTILS_VALID_LINE.match(logical_line)):
@@ -113,6 +115,7 @@ def use_jsonutils(logical_line, filename):
" of json")
+@core.flake8ext
def no_mutable_default_args(logical_line):
"""Check to prevent mutable default argument in sahara code.
@@ -121,18 +124,3 @@ def no_mutable_default_args(logical_line):
msg = "S360: Method's default argument shouldn't be mutable!"
if RE_MUTABLE_DEFAULT_ARGS.match(logical_line):
yield (0, msg)
-
-
-def factory(register):
- register(import_db_only_in_conductor)
- register(hacking_no_author_attr)
- register(check_oslo_namespace_imports)
- register(commit_message.OnceGitCheckCommitTitleBug)
- register(commit_message.OnceGitCheckCommitTitleLength)
- register(import_checks.hacking_import_groups)
- register(import_checks.hacking_import_groups_together)
- register(dict_constructor_with_list_copy)
- register(logging_checks.no_translate_logs)
- register(logging_checks.accepted_log_levels)
- register(use_jsonutils)
- register(no_mutable_default_args)