Merge "Added hacking check to ensure LOG.warn is not used"
This commit is contained in:
commit
01072cad4e
@ -23,3 +23,4 @@ Magnum Specific Commandments
|
|||||||
with a sequence of key-value pairs.
|
with a sequence of key-value pairs.
|
||||||
- [M338] Use assertIn/NotIn(A, B) rather than assertEqual(A in B, True/False).
|
- [M338] Use assertIn/NotIn(A, B) rather than assertEqual(A in B, True/False).
|
||||||
- [M339] Don't use xrange()
|
- [M339] Don't use xrange()
|
||||||
|
- [M352] LOG.warn is deprecated. Enforce use of LOG.warning.
|
||||||
|
@ -144,6 +144,20 @@ def dict_constructor_with_list_copy(logical_line):
|
|||||||
yield (0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
|
def no_log_warn(logical_line):
|
||||||
|
"""Disallow 'LOG.warn('
|
||||||
|
|
||||||
|
Deprecated LOG.warn(), instead use LOG.warning
|
||||||
|
https://bugs.launchpad.net/magnum/+bug/1508442
|
||||||
|
|
||||||
|
M352
|
||||||
|
"""
|
||||||
|
|
||||||
|
msg = ("M352: LOG.warn is deprecated, please use LOG.warning!")
|
||||||
|
if "LOG.warn(" in logical_line:
|
||||||
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
def factory(register):
|
def factory(register):
|
||||||
register(no_mutable_default_args)
|
register(no_mutable_default_args)
|
||||||
register(assert_equal_none)
|
register(assert_equal_none)
|
||||||
@ -154,3 +168,4 @@ def factory(register):
|
|||||||
register(use_timeutils_utcnow)
|
register(use_timeutils_utcnow)
|
||||||
register(dict_constructor_with_list_copy)
|
register(dict_constructor_with_list_copy)
|
||||||
register(no_xrange)
|
register(no_xrange)
|
||||||
|
register(no_log_warn)
|
||||||
|
@ -189,6 +189,19 @@ class HackingTestCase(base.TestCase):
|
|||||||
code = "range(45)"
|
code = "range(45)"
|
||||||
self._assert_has_no_errors(code, check)
|
self._assert_has_no_errors(code, check)
|
||||||
|
|
||||||
|
def test_no_log_warn(self):
|
||||||
|
errors = [(1, 0, "M352")]
|
||||||
|
check = checks.no_log_warn
|
||||||
|
code = """
|
||||||
|
LOG.warn("LOG.warn is deprecated")
|
||||||
|
"""
|
||||||
|
self._assert_has_errors(code, check, errors)
|
||||||
|
|
||||||
|
code = """
|
||||||
|
LOG.warning("LOG.warn is deprecated")
|
||||||
|
"""
|
||||||
|
self._assert_has_no_errors(code, check)
|
||||||
|
|
||||||
def test_use_timeunitls_utcow(self):
|
def test_use_timeunitls_utcow(self):
|
||||||
errors = [(1, 0, "M310")]
|
errors = [(1, 0, "M310")]
|
||||||
check = checks.use_timeutils_utcnow
|
check = checks.use_timeutils_utcnow
|
||||||
|
Loading…
Reference in New Issue
Block a user