Skip to content

Commit

Permalink
Fix the duplicate hacking check M312 and H203
Browse files Browse the repository at this point in the history
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
  • Loading branch information
junboli committed Aug 13, 2017
1 parent 80fe5f1 commit ca712cb
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 17 deletions.
1 change: 0 additions & 1 deletion HACKING.rst
Expand Up @@ -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().
Expand Down
9 changes: 0 additions & 9 deletions manila/hacking/checks.py
Expand Up @@ -51,7 +51,6 @@
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\(.*")


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 changes: 0 additions & 7 deletions manila/tests/test_hacking.py
Expand Up @@ -314,13 +314,6 @@ def test_validate_assertTrue(self):
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()
Expand Down

0 comments on commit ca712cb

Please sign in to comment.