Added hacking check to ensure LOG.warn is not used
LOG.warn is deprecated. To ensure it is not used later added hacking check. Change-Id: Iadd1d4f4588c9d47baefd685a97a73c8b1aee987 Closes-Bug: #1605711
This commit is contained in:
parent
921e3f88df
commit
5c2fc0b392
@ -23,3 +23,4 @@ Magnum Specific Commandments
|
||||
with a sequence of key-value pairs.
|
||||
- [M338] Use assertIn/NotIn(A, B) rather than assertEqual(A in B, True/False).
|
||||
- [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)
|
||||
|
||||
|
||||
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):
|
||||
register(no_mutable_default_args)
|
||||
register(assert_equal_none)
|
||||
@ -154,3 +168,4 @@ def factory(register):
|
||||
register(use_timeutils_utcnow)
|
||||
register(dict_constructor_with_list_copy)
|
||||
register(no_xrange)
|
||||
register(no_log_warn)
|
||||
|
@ -189,6 +189,19 @@ class HackingTestCase(base.TestCase):
|
||||
code = "range(45)"
|
||||
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):
|
||||
errors = [(1, 0, "M310")]
|
||||
check = checks.use_timeutils_utcnow
|
||||
|
Loading…
Reference in New Issue
Block a user