Add a hacking rule for string interpolation at logging
String interpolation should be delayed to be handled by the logging code, rather than being done at the point of the logging call. See the oslo i18n guideline * https://docs.openstack.org/oslo.i18n/latest/user/guidelines.html#adding-variables-to-log-messages and * https://github.com/openstack-dev/hacking/blob/master/hacking/checks/other.py#L39 Closes-Bug: #1596829 Change-Id: Iba231be2476dcbeeb0edd76d6a921e549d183758
This commit is contained in:
parent
33b0ec1397
commit
d02a66d6bf
@ -504,10 +504,10 @@ class DbSync(BaseApp):
|
|||||||
LOG.info('The latest installed migration script version is: '
|
LOG.info('The latest installed migration script version is: '
|
||||||
'%(script)d.\nCurrent repository versions:\nExpand: '
|
'%(script)d.\nCurrent repository versions:\nExpand: '
|
||||||
'%(expand)d \nMigrate: %(migrate)d\nContract: '
|
'%(expand)d \nMigrate: %(migrate)d\nContract: '
|
||||||
'%(contract)d' % {'script': migration_script_version,
|
'%(contract)d', {'script': migration_script_version,
|
||||||
'expand': expand_version,
|
'expand': expand_version,
|
||||||
'migrate': migrate_version,
|
'migrate': migrate_version,
|
||||||
'contract': contract_version})
|
'contract': contract_version})
|
||||||
return status
|
return status
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -96,7 +96,7 @@ class FernetUtils(object):
|
|||||||
LOG.warning(
|
LOG.warning(
|
||||||
'Unable to change the ownership of key_repository without '
|
'Unable to change the ownership of key_repository without '
|
||||||
'a keystone user ID and keystone group ID both being '
|
'a keystone user ID and keystone group ID both being '
|
||||||
'provided: %s' % self.key_repository)
|
'provided: %s', self.key_repository)
|
||||||
|
|
||||||
def _create_new_key(self, keystone_user_id, keystone_group_id):
|
def _create_new_key(self, keystone_user_id, keystone_group_id):
|
||||||
"""Securely create a new encryption key.
|
"""Securely create a new encryption key.
|
||||||
@ -128,8 +128,7 @@ class FernetUtils(object):
|
|||||||
LOG.warning(
|
LOG.warning(
|
||||||
'Unable to change the ownership of the new key without a '
|
'Unable to change the ownership of the new key without a '
|
||||||
'keystone user ID and keystone group ID both being provided: '
|
'keystone user ID and keystone group ID both being provided: '
|
||||||
'%s' %
|
'%s', self.key_repository)
|
||||||
self.key_repository)
|
|
||||||
# Determine the file name of the new key
|
# Determine the file name of the new key
|
||||||
key_file = os.path.join(self.key_repository, '0.tmp')
|
key_file = os.path.join(self.key_repository, '0.tmp')
|
||||||
create_success = False
|
create_success = False
|
||||||
|
@ -214,7 +214,7 @@ class Resource(base.ResourceDriverBase):
|
|||||||
if (project_id not in project_ids_from_bd or
|
if (project_id not in project_ids_from_bd or
|
||||||
project_id == base.NULL_DOMAIN_ID):
|
project_id == base.NULL_DOMAIN_ID):
|
||||||
LOG.warning('Project %s does not exist and was not '
|
LOG.warning('Project %s does not exist and was not '
|
||||||
'deleted.' % project_id)
|
'deleted.', project_id)
|
||||||
query.delete(synchronize_session=False)
|
query.delete(synchronize_session=False)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1353,7 +1353,7 @@ class DomainConfigManager(manager.Manager):
|
|||||||
'value: %(value)s.')
|
'value: %(value)s.')
|
||||||
|
|
||||||
if warning_msg:
|
if warning_msg:
|
||||||
LOG.warning(warning_msg % {
|
LOG.warning(warning_msg, {
|
||||||
'domain': domain_id,
|
'domain': domain_id,
|
||||||
'group': each_whitelisted['group'],
|
'group': each_whitelisted['group'],
|
||||||
'option': each_whitelisted['option'],
|
'option': each_whitelisted['option'],
|
||||||
|
@ -347,7 +347,7 @@ class FakeLdap(common.LDAPHandler):
|
|||||||
id_attr_in_modlist = True
|
id_attr_in_modlist = True
|
||||||
|
|
||||||
if not id_attr_in_modlist:
|
if not id_attr_in_modlist:
|
||||||
LOG.debug('id_attribute=%(attr)s missing, attributes=%(attrs)s' %
|
LOG.debug('id_attribute=%(attr)s missing, attributes=%(attrs)s',
|
||||||
{'attr': id_attr, 'attrs': modlist})
|
{'attr': id_attr, 'attrs': modlist})
|
||||||
raise ldap.NAMING_VIOLATION
|
raise ldap.NAMING_VIOLATION
|
||||||
key = self.key(dn)
|
key = self.key(dn)
|
||||||
|
@ -557,7 +557,7 @@ class DomainConfigTests(object):
|
|||||||
with mock.patch('keystone.resource.core.LOG', mock_log):
|
with mock.patch('keystone.resource.core.LOG', mock_log):
|
||||||
res = self.domain_config_api.get_config_with_sensitive_info(
|
res = self.domain_config_api.get_config_with_sensitive_info(
|
||||||
self.domain['id'])
|
self.domain['id'])
|
||||||
mock_log.warning.assert_any_call(mock.ANY)
|
mock_log.warning.assert_any_call(mock.ANY, mock.ANY)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
invalid_option_config['ldap']['url'], res['ldap']['url'])
|
invalid_option_config['ldap']['url'], res['ldap']['url'])
|
||||||
|
|
||||||
|
2
tox.ini
2
tox.ini
@ -99,7 +99,7 @@ passenv =
|
|||||||
[flake8]
|
[flake8]
|
||||||
filename= *.py,keystone-manage
|
filename= *.py,keystone-manage
|
||||||
show-source = true
|
show-source = true
|
||||||
enable-extensions = H203
|
enable-extensions = H203,H904
|
||||||
|
|
||||||
# D100: Missing docstring in public module
|
# D100: Missing docstring in public module
|
||||||
# D101: Missing docstring in public class
|
# D101: Missing docstring in public class
|
||||||
|
Loading…
Reference in New Issue
Block a user