Catch .format() use in log string interpoliation check
This adds checking for using .format() instead of % when looking for cases of preformatting log strings. Change-Id: Ia12f898ca3d206c9da0e5057c7223e124ee2548c Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
parent
31e9c8751e
commit
f82f995d02
@ -55,5 +55,5 @@ def hacking_delayed_string_interpolation(logical_line, noqa):
|
||||
# There are some cases where string formatting of the arguments are
|
||||
# needed, so don't include those when checking.
|
||||
line = re.sub(r",.*", '', line)
|
||||
if '%' in line:
|
||||
if '%' in line or '.format' in line:
|
||||
yield 0, msg
|
||||
|
@ -25,6 +25,7 @@ class OthersTestCase(tests.TestCase):
|
||||
@ddt.data(
|
||||
(1, 'LOG.debug("Test %s" % foo)', None),
|
||||
(0, 'LOG.info("Test %s", foo)', None),
|
||||
(1, 'LOG.info("Test {}".format(foo))', None),
|
||||
(0, 'LOG.error("Test %s" % foo)', '# noqa'),
|
||||
(1, 'LOG.debug("Test %s" % "foo")', None),
|
||||
(0, 'LOG.debug("Test %s", "foo")', None),
|
||||
|
Loading…
x
Reference in New Issue
Block a user