Browse Source

Fix the duplicate hacking check M312 and H203

The hacking "[H203] Use assertIs(Not)None to check for None" is already enabled
in tox. But the local hacking M312 is also avaliable, there is no need to check
twice here for the same check.

Change-Id: I56e19c6dd8905e439247c3b142e74913b5d0d7a6
Closes-Bug: #1710426
changes/40/493340/1
junboli 4 years ago
parent
commit
ca712cb0bd
  1. 1
      HACKING.rst
  2. 9
      manila/hacking/checks.py
  3. 7
      manila/tests/test_hacking.py

1
HACKING.rst

@ -10,7 +10,6 @@ Manila Specific Commandments
----------------------------
- [M310] Check for improper use of logging format arguments.
- [M312] Use assertIsNone(...) instead of assertEqual(None, ...).
- [M313] Use assertTrue(...) rather than assertEqual(True, ...).
- [M323] Ensure that the _() function is explicitly imported to ensure proper translations.
- [M325] str() and unicode() cannot be used on an exception. Remove or use six.text_type().

9
manila/hacking/checks.py

@ -51,7 +51,6 @@ oslo_namespace_imports = re.compile(r"from[\s]*oslo[.](.*)")
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"\s*LOG.warn\(.*")
@ -290,13 +289,6 @@ def validate_assertTrue(logical_line):
yield(0, msg)
def validate_assertIsNone(logical_line):
if re.match(assert_None, logical_line):
msg = ("M312: Unit tests should use assertIsNone(value) instead"
" of using assertEqual(None, value).")
yield(0, msg)
def check_uuid4(logical_line):
"""Generating UUID
@ -338,6 +330,5 @@ def factory(register):
register(dict_constructor_with_list_copy)
register(no_xrange)
register(validate_assertTrue)
register(validate_assertIsNone)
register(check_uuid4)
register(no_log_warn_check)

7
manila/tests/test_hacking.py

@ -314,13 +314,6 @@ class HackingTestCase(test.TestCase):
self.assertEqual(1, len(list(checks.validate_assertTrue(
"assertEqual(True, %s)" % test_value))))
def test_validate_assertIsNone(self):
test_value = None
self.assertEqual(0, len(list(checks.validate_assertIsNone(
"assertIsNone(None)"))))
self.assertEqual(1, len(list(checks.validate_assertIsNone(
"assertEqual(None, %s)" % test_value))))
def test_check_uuid4(self):
code = """
fake_uuid = uuid.uuid4()

Loading…
Cancel
Save