Drop redundant hacking check for xrange
xrange no longer exists in Python 3 and it is caught by the core check (as an undefined method). Also remove a few unused regex patterns. Change-Id: I6b7cb5fc67b84fa95ef7180d7b16e77105c22522 Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
@@ -16,7 +16,6 @@ Cloudkitty Specific Commandments
|
||||
included in translated message.
|
||||
- [C318] Must use a dict comprehension instead of a dict constructor
|
||||
with a sequence of key-value pairs.
|
||||
- [C319] Ensure to not use xrange().
|
||||
- [C320] Do not use LOG.warn as it's deprecated.
|
||||
- [C321] Ensure that the _() function is explicitly imported to ensure
|
||||
proper translations.
|
||||
|
||||
@@ -47,11 +47,7 @@ underscore_import_check_multi = re.compile(r"(.)*import (.)*_, (.)*")
|
||||
# We need this for cases where they have created their own _ function.
|
||||
custom_underscore_check = re.compile(r"(.)*_\s*=\s*(.)*")
|
||||
dict_constructor_with_list_copy_re = re.compile(r".*\bdict\((\[)?(\(|\[)")
|
||||
assert_no_xrange_re = re.compile(r"\s*xrange\s*\(")
|
||||
assert_True = re.compile(r".*assertEqual\(True, .*\)")
|
||||
assert_None = re.compile(r".*assertEqual\(None, .*\)")
|
||||
no_log_warn = re.compile(r".*LOG.warn\(.*\)")
|
||||
asse_raises_regexp = re.compile(r"assertRaisesRegexp\(")
|
||||
|
||||
|
||||
class BaseASTChecker(ast.NodeVisitor):
|
||||
@@ -294,16 +290,6 @@ def dict_constructor_with_list_copy(logical_line):
|
||||
yield (0, msg)
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def no_xrange(logical_line):
|
||||
"""Ensure to not use xrange()
|
||||
|
||||
C319
|
||||
"""
|
||||
if assert_no_xrange_re.match(logical_line):
|
||||
yield (0, "C319: Do not use xrange().")
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def no_log_warn_check(logical_line):
|
||||
"""Disallow 'LOG.warn'
|
||||
|
||||
@@ -280,11 +280,6 @@ class HackingTestCase(tests.TestCase):
|
||||
self.assertEqual(0, len(list(checks.dict_constructor_with_list_copy(
|
||||
" self._render_dict(xml, data_el, data.__dict__)"))))
|
||||
|
||||
def test_no_xrange(self):
|
||||
self.assertEqual(1, len(list(checks.no_xrange("xrange(45)"))))
|
||||
|
||||
self.assertEqual(0, len(list(checks.no_xrange("range(45)"))))
|
||||
|
||||
def test_no_log_warn_check(self):
|
||||
self.assertEqual(0, len(list(checks.no_log_warn_check(
|
||||
"LOG.warning('This should not trigger LOG.warn"
|
||||
|
||||
Reference in New Issue
Block a user