コード例 #1
0
# pylint: disable=E1101, no-absolute-import
"""test checking use of the logging module
"""

__revision__ = ''

# Muck up the names in an effort to confuse...
import logging as renamed_logging
import os as logging

# Statements that should be flagged:
renamed_logging.warn('%s, %s' % (4, 5))
renamed_logging.exception('%s' % 'Exceptional!')
renamed_logging.log(renamed_logging.INFO, 'msg: %s' % 'Run!')

# Statements that should not be flagged:
renamed_logging.warn('%s, %s', 4, 5)
renamed_logging.log(renamed_logging.INFO, 'msg: %s', 'Run!')
renamed_logging.warn('%s' + ' the rest of a single string')
logging.warn('%s, %s' % (4, 5))
logging.log(logging.INFO, 'msg: %s' % 'Run!')
コード例 #2
0
# pylint: disable=missing-docstring,no-member,deprecated-method,invalid-name

# Muck up the names in an effort to confuse...
import logging as renamed_logging
import os as logging

var = "123"
var_name = "Var:"
# Statements that should be flagged:
renamed_logging.warn("%s, %s" % (4, 5))  # [logging-not-lazy]
renamed_logging.exception("%s" % "Exceptional!")  # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO,
                    "msg: %s" % "Run!")  # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO, "Var: " + var)  # [logging-not-lazy]
renamed_logging.warn("%s" +
                     " the rest of a single string")  # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO, var_name + var)  # [logging-not-lazy]

var_name = "Var:"
# Statements that should not be flagged:
renamed_logging.warn("%s, %s", 4, 5)
renamed_logging.log(renamed_logging.INFO, "msg: %s", "Run!")
logging.warn("%s, %s" % (4, 5))
logging.log(logging.INFO, "msg: %s" % "Run!")
logging.log("Var: " + var)