Bump hacking
hacking 3.0.x is too old. Also fix failures detected by the new hacking version. Change-Id: Ifccbbf2ff7b0824d2079937526d3eee1c536349b
This commit is contained in:
parent
a9ccce8b0c
commit
813f229a08
@ -50,8 +50,8 @@ done in the OpenStack CI systems.
|
|||||||
Heat Specific Commandments
|
Heat Specific Commandments
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
- [Heat301] Use LOG.warning() rather than LOG.warn().
|
- [HE301] Use LOG.warning() rather than LOG.warn().
|
||||||
- [Heat302] Python 3: do not use dict.iteritems.
|
- [HE302] Python 3: do not use dict.iteritems.
|
||||||
- [Heat303] Python 3: do not use dict.iterkeys.
|
- [HE303] Python 3: do not use dict.iterkeys.
|
||||||
- [Heat304] Python 3: do not use dict.itervalues.
|
- [HE304] Python 3: do not use dict.itervalues.
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
def list_types():
|
def list_types():
|
||||||
return(["text/x-cfninitdata"])
|
return ["text/x-cfninitdata"]
|
||||||
|
|
||||||
|
|
||||||
def handle_part(data, ctype, filename, payload):
|
def handle_part(data, ctype, filename, payload):
|
||||||
|
@ -277,7 +277,7 @@ class KsClientWrapper(object):
|
|||||||
return trust_context
|
return trust_context
|
||||||
|
|
||||||
def _get_username(self, username):
|
def _get_username(self, username):
|
||||||
if(len(username) > 255):
|
if len(username) > 255:
|
||||||
LOG.warning("Truncating the username %s to the last 255 "
|
LOG.warning("Truncating the username %s to the last 255 "
|
||||||
"characters.", username)
|
"characters.", username)
|
||||||
# get the last 255 characters of the username
|
# get the last 255 characters of the username
|
||||||
|
@ -809,7 +809,7 @@ class Resource(status.ResourceStatus):
|
|||||||
if endpoint_exists:
|
if endpoint_exists:
|
||||||
req_extension = cls.required_service_extension
|
req_extension = cls.required_service_extension
|
||||||
if not req_extension:
|
if not req_extension:
|
||||||
return(True, None)
|
return (True, None)
|
||||||
if isinstance(req_extension, str):
|
if isinstance(req_extension, str):
|
||||||
req_extension = re.split(' |,', req_extension)
|
req_extension = re.split(' |,', req_extension)
|
||||||
for ext in req_extension:
|
for ext in req_extension:
|
||||||
|
@ -545,7 +545,7 @@ class Port(neutron.NeutronResource):
|
|||||||
).get_secgroup_uuids(['default'])
|
).get_secgroup_uuids(['default'])
|
||||||
|
|
||||||
if self.REPLACEMENT_POLICY in props:
|
if self.REPLACEMENT_POLICY in props:
|
||||||
del(props[self.REPLACEMENT_POLICY])
|
del props[self.REPLACEMENT_POLICY]
|
||||||
|
|
||||||
def _store_config_default_properties(self, attrs):
|
def _store_config_default_properties(self, attrs):
|
||||||
"""A method for storing properties default values.
|
"""A method for storing properties default values.
|
||||||
|
@ -180,7 +180,7 @@ class SecurityGroup(neutron.NeutronResource):
|
|||||||
|
|
||||||
if 'remote_mode' in rule:
|
if 'remote_mode' in rule:
|
||||||
remote_mode = rule.get(self.RULE_REMOTE_MODE)
|
remote_mode = rule.get(self.RULE_REMOTE_MODE)
|
||||||
del(rule[self.RULE_REMOTE_MODE])
|
del rule[self.RULE_REMOTE_MODE]
|
||||||
|
|
||||||
if remote_mode == self.RULE_REMOTE_GROUP_ID:
|
if remote_mode == self.RULE_REMOTE_GROUP_ID:
|
||||||
rule[self.RULE_REMOTE_IP_PREFIX] = None
|
rule[self.RULE_REMOTE_IP_PREFIX] = None
|
||||||
|
@ -1343,7 +1343,7 @@ class Stack(collections.abc.Mapping):
|
|||||||
elif create_if_missing:
|
elif create_if_missing:
|
||||||
kwargs = self.get_kwargs_for_cloning(keep_tags=True)
|
kwargs = self.get_kwargs_for_cloning(keep_tags=True)
|
||||||
kwargs['owner_id'] = self.id
|
kwargs['owner_id'] = self.id
|
||||||
del(kwargs['prev_raw_template_id'])
|
del kwargs['prev_raw_template_id']
|
||||||
prev = type(self)(self.context, self._backup_name(),
|
prev = type(self)(self.context, self._backup_name(),
|
||||||
copy.deepcopy(self.t),
|
copy.deepcopy(self.t),
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
@ -26,7 +26,7 @@ Guidelines for writing new hacking checks
|
|||||||
- Pick numbers in the range H3xx. Find the current test with
|
- Pick numbers in the range H3xx. Find the current test with
|
||||||
the highest allocated number and then pick the next value.
|
the highest allocated number and then pick the next value.
|
||||||
- Keep the test method code in the source file ordered based
|
- Keep the test method code in the source file ordered based
|
||||||
on the Heat3xx value.
|
on the HE3xx value.
|
||||||
- List the new rule in the top level HACKING.rst file
|
- List the new rule in the top level HACKING.rst file
|
||||||
- Add test cases for each new rule to heat/tests/test_hacking.py
|
- Add test cases for each new rule to heat/tests/test_hacking.py
|
||||||
|
|
||||||
@ -39,31 +39,31 @@ def no_log_warn(logical_line):
|
|||||||
|
|
||||||
https://bugs.launchpad.net/tempest/+bug/1508442
|
https://bugs.launchpad.net/tempest/+bug/1508442
|
||||||
|
|
||||||
Heat301
|
HE301
|
||||||
"""
|
"""
|
||||||
if logical_line.startswith('LOG.warn('):
|
if logical_line.startswith('LOG.warn('):
|
||||||
yield(0, 'Heat301 Use LOG.warning() rather than LOG.warn()')
|
yield (0, 'HE301 Use LOG.warning() rather than LOG.warn()')
|
||||||
|
|
||||||
|
|
||||||
@core.flake8ext
|
@core.flake8ext
|
||||||
def check_python3_no_iteritems(logical_line):
|
def check_python3_no_iteritems(logical_line):
|
||||||
msg = ("Heat302: Use dict.items() instead of dict.iteritems().")
|
msg = ("HE302: Use dict.items() instead of dict.iteritems().")
|
||||||
|
|
||||||
if re.search(r".*\.iteritems\(\)", logical_line):
|
if re.search(r".*\.iteritems\(\)", logical_line):
|
||||||
yield(0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
@core.flake8ext
|
@core.flake8ext
|
||||||
def check_python3_no_iterkeys(logical_line):
|
def check_python3_no_iterkeys(logical_line):
|
||||||
msg = ("Heat303: Use dict.keys() instead of dict.iterkeys().")
|
msg = ("HE303: Use dict.keys() instead of dict.iterkeys().")
|
||||||
|
|
||||||
if re.search(r".*\.iterkeys\(\)", logical_line):
|
if re.search(r".*\.iterkeys\(\)", logical_line):
|
||||||
yield(0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
@core.flake8ext
|
@core.flake8ext
|
||||||
def check_python3_no_itervalues(logical_line):
|
def check_python3_no_itervalues(logical_line):
|
||||||
msg = ("Heat304: Use dict.values() instead of dict.itervalues().")
|
msg = ("HE304: Use dict.values() instead of dict.itervalues().")
|
||||||
|
|
||||||
if re.search(r".*\.itervalues\(\)", logical_line):
|
if re.search(r".*\.itervalues\(\)", logical_line):
|
||||||
yield(0, msg)
|
yield (0, msg)
|
||||||
|
@ -266,8 +266,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||||||
u'stack_status': u'COMPLETE',
|
u'stack_status': u'COMPLETE',
|
||||||
u'description': u'blah',
|
u'description': u'blah',
|
||||||
u'disable_rollback': 'true',
|
u'disable_rollback': 'true',
|
||||||
u'timeout_mins':60,
|
u'timeout_mins': 60,
|
||||||
u'capabilities':[]}]
|
u'capabilities': []}]
|
||||||
|
|
||||||
self.m_call.side_effect = [identity, engine_resp]
|
self.m_call.side_effect = [identity, engine_resp]
|
||||||
|
|
||||||
@ -358,8 +358,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||||||
u'stack_status': u'COMPLETE',
|
u'stack_status': u'COMPLETE',
|
||||||
u'description': u'blah',
|
u'description': u'blah',
|
||||||
u'disable_rollback': 'true',
|
u'disable_rollback': 'true',
|
||||||
u'timeout_mins':60,
|
u'timeout_mins': 60,
|
||||||
u'capabilities':[]}]
|
u'capabilities': []}]
|
||||||
|
|
||||||
self.m_call.return_value = engine_resp
|
self.m_call.return_value = engine_resp
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ class RoutesTest(common.HeatTestCase):
|
|||||||
class_name = reflection.get_class_name(route['controller'].controller,
|
class_name = reflection.get_class_name(route['controller'].controller,
|
||||||
fully_qualified=False)
|
fully_qualified=False)
|
||||||
self.assertEqual(controller, class_name)
|
self.assertEqual(controller, class_name)
|
||||||
del(route['action'])
|
del route['action']
|
||||||
del(route['controller'])
|
del route['controller']
|
||||||
self.assertEqual(params, route)
|
self.assertEqual(params, route)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -1608,7 +1608,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||||||
u'stack_status': u'COMPLETE',
|
u'stack_status': u'COMPLETE',
|
||||||
u'description': u'blah',
|
u'description': u'blah',
|
||||||
u'disable_rollback': True,
|
u'disable_rollback': True,
|
||||||
u'timeout_mins':60,
|
u'timeout_mins': 60,
|
||||||
u'capabilities': [],
|
u'capabilities': [],
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -1674,7 +1674,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||||||
u'stack_status': u'COMPLETE',
|
u'stack_status': u'COMPLETE',
|
||||||
u'description': u'blah',
|
u'description': u'blah',
|
||||||
u'disable_rollback': True,
|
u'disable_rollback': True,
|
||||||
u'timeout_mins':60,
|
u'timeout_mins': 60,
|
||||||
u'capabilities': [],
|
u'capabilities': [],
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -54,13 +54,13 @@ class Engine(message_processor.MessageProcessor):
|
|||||||
if props:
|
if props:
|
||||||
props_def = {}
|
props_def = {}
|
||||||
for prop_name, prop_value in props.items():
|
for prop_name, prop_value in props.items():
|
||||||
if type(prop_value) == scenario_template.GetRes:
|
if isinstance(prop_value, scenario_template.GetAtt):
|
||||||
prop_res = getattr(prop_value, "target_name")
|
|
||||||
prop_value = {'get_resource': prop_res}
|
|
||||||
elif type(prop_value) == scenario_template.GetAtt:
|
|
||||||
prop_res = getattr(prop_value, "target_name")
|
prop_res = getattr(prop_value, "target_name")
|
||||||
prop_attr = getattr(prop_value, "attr")
|
prop_attr = getattr(prop_value, "attr")
|
||||||
prop_value = {'get_attr': [prop_res, prop_attr]}
|
prop_value = {'get_attr': [prop_res, prop_attr]}
|
||||||
|
elif isinstance(prop_value, scenario_template.GetRes):
|
||||||
|
prop_res = getattr(prop_value, "target_name")
|
||||||
|
prop_value = {'get_resource': prop_res}
|
||||||
props_def[prop_name] = prop_value
|
props_def[prop_name] = prop_value
|
||||||
res_defn["properties"] = props_def
|
res_defn["properties"] = props_def
|
||||||
if depends:
|
if depends:
|
||||||
|
@ -76,7 +76,7 @@ outputs:
|
|||||||
before_refid = self.rsrc.FnGetRefId()
|
before_refid = self.rsrc.FnGetRefId()
|
||||||
self.assertIsNotNone(before_refid)
|
self.assertIsNotNone(before_refid)
|
||||||
new_t = self.t.copy()
|
new_t = self.t.copy()
|
||||||
del(new_t['resources']['none']['properties']['ignored'])
|
del new_t['resources']['none']['properties']['ignored']
|
||||||
utils.update_stack(self.stack, new_t)
|
utils.update_stack(self.stack, new_t)
|
||||||
self.assertEqual((self.stack.UPDATE, self.stack.COMPLETE),
|
self.assertEqual((self.stack.UPDATE, self.stack.COMPLETE),
|
||||||
self.stack.state)
|
self.stack.state)
|
||||||
|
@ -368,7 +368,7 @@ class RemoteStackTest(tests_common.HeatTestCase):
|
|||||||
ca_cert=ca_cert)
|
ca_cert=ca_cert)
|
||||||
self.assertEqual(ca_cert, rsrc._cacert)
|
self.assertEqual(ca_cert, rsrc._cacert)
|
||||||
self.assertEqual(ca_cert, rsrc.cacert)
|
self.assertEqual(ca_cert, rsrc.cacert)
|
||||||
self.assertTrue('/tmp/' in rsrc._ssl_verify)
|
self.assertIn('/tmp/', rsrc._ssl_verify)
|
||||||
|
|
||||||
def test_create_with_insecure(self):
|
def test_create_with_insecure(self):
|
||||||
rsrc = self._create_with_remote_credential(insecure=True)
|
rsrc = self._create_with_remote_credential(insecure=True)
|
||||||
|
@ -1318,7 +1318,7 @@ class SoftwareDeploymentTest(common.HeatTestCase):
|
|||||||
mock.call('swift_signal_url')],
|
mock.call('swift_signal_url')],
|
||||||
self.deployment.data_delete.mock_calls)
|
self.deployment.data_delete.mock_calls)
|
||||||
|
|
||||||
del(dep_data['swift_signal_object_name'])
|
del dep_data['swift_signal_object_name']
|
||||||
self.deployment.physical_resource_name = mock.Mock()
|
self.deployment.physical_resource_name = mock.Mock()
|
||||||
self.deployment._delete_swift_signal_url()
|
self.deployment._delete_swift_signal_url()
|
||||||
self.assertFalse(self.deployment.physical_resource_name.called)
|
self.assertFalse(self.deployment.physical_resource_name.called)
|
||||||
|
@ -156,10 +156,10 @@ class NeutronFloatingIPTest(common.HeatTestCase):
|
|||||||
raise ex
|
raise ex
|
||||||
|
|
||||||
def find_network_port(self, value):
|
def find_network_port(self, value):
|
||||||
return('9c1eb3fe-7bba-479d-bd43-fdb0bc7cd151')
|
return '9c1eb3fe-7bba-479d-bd43-fdb0bc7cd151'
|
||||||
|
|
||||||
def find_network_ip(self, value):
|
def find_network_ip(self, value):
|
||||||
return('477e8273-60a7-4c41-b683-1d497e53c384')
|
return '477e8273-60a7-4c41-b683-1d497e53c384'
|
||||||
|
|
||||||
self.ctx = utils.dummy_context()
|
self.ctx = utils.dummy_context()
|
||||||
tpl = template_format.parse(neutron_floating_template)
|
tpl = template_format.parse(neutron_floating_template)
|
||||||
@ -694,7 +694,7 @@ class NeutronFloatingIPTest(common.HeatTestCase):
|
|||||||
|
|
||||||
# test update FloatingIp with None port_id
|
# test update FloatingIp with None port_id
|
||||||
props = copy.deepcopy(fip.properties.data)
|
props = copy.deepcopy(fip.properties.data)
|
||||||
del(props['port_id'])
|
del props['port_id']
|
||||||
update_snippet = rsrc_defn.ResourceDefinition(fip.name, fip.type(),
|
update_snippet = rsrc_defn.ResourceDefinition(fip.name, fip.type(),
|
||||||
stack.t.parse(stack.defn,
|
stack.t.parse(stack.defn,
|
||||||
props))
|
props))
|
||||||
|
@ -125,7 +125,7 @@ class TestRequestContext(common.HeatTestCase):
|
|||||||
user_domain_id=ctx_origin.get('user_domain_id'),
|
user_domain_id=ctx_origin.get('user_domain_id'),
|
||||||
project_domain_id=ctx_origin.get('project_domain_id'))
|
project_domain_id=ctx_origin.get('project_domain_id'))
|
||||||
ctx_dict = ctx.to_dict()
|
ctx_dict = ctx.to_dict()
|
||||||
del(ctx_dict['request_id'])
|
del ctx_dict['request_id']
|
||||||
self.assertEqual(ctx_origin, ctx_dict)
|
self.assertEqual(ctx_origin, ctx_dict)
|
||||||
|
|
||||||
def test_request_context_from_dict(self):
|
def test_request_context_from_dict(self):
|
||||||
|
@ -47,7 +47,7 @@ class EnvironmentTest(common.HeatTestCase):
|
|||||||
u'resource_registry': {u'resources': {}}}
|
u'resource_registry': {u'resources': {}}}
|
||||||
env = environment.Environment(old)
|
env = environment.Environment(old)
|
||||||
self.assertEqual(expected, env.env_as_dict())
|
self.assertEqual(expected, env.env_as_dict())
|
||||||
del(expected['encrypted_param_names'])
|
del expected['encrypted_param_names']
|
||||||
self.assertEqual(expected, env.user_env_as_dict())
|
self.assertEqual(expected, env.user_env_as_dict())
|
||||||
|
|
||||||
def test_load_new_env(self):
|
def test_load_new_env(self):
|
||||||
@ -59,7 +59,7 @@ class EnvironmentTest(common.HeatTestCase):
|
|||||||
u'resources': {}}}
|
u'resources': {}}}
|
||||||
env = environment.Environment(new_env)
|
env = environment.Environment(new_env)
|
||||||
self.assertEqual(new_env, env.env_as_dict())
|
self.assertEqual(new_env, env.env_as_dict())
|
||||||
del(new_env['encrypted_param_names'])
|
del new_env['encrypted_param_names']
|
||||||
self.assertEqual(new_env, env.user_env_as_dict())
|
self.assertEqual(new_env, env.user_env_as_dict())
|
||||||
|
|
||||||
def test_global_registry(self):
|
def test_global_registry(self):
|
||||||
|
@ -56,12 +56,12 @@ class JsonToYamlTest(common.HeatTestCase):
|
|||||||
|
|
||||||
self.assertEqual(u'2012-12-12', yml[u'HeatTemplateFormatVersion'])
|
self.assertEqual(u'2012-12-12', yml[u'HeatTemplateFormatVersion'])
|
||||||
self.assertNotIn(u'AWSTemplateFormatVersion', yml)
|
self.assertNotIn(u'AWSTemplateFormatVersion', yml)
|
||||||
del(yml[u'HeatTemplateFormatVersion'])
|
del yml[u'HeatTemplateFormatVersion']
|
||||||
|
|
||||||
jsn = template_format.parse(json_str)
|
jsn = template_format.parse(json_str)
|
||||||
|
|
||||||
if u'AWSTemplateFormatVersion' in jsn:
|
if u'AWSTemplateFormatVersion' in jsn:
|
||||||
del(jsn[u'AWSTemplateFormatVersion'])
|
del jsn[u'AWSTemplateFormatVersion']
|
||||||
|
|
||||||
self.assertEqual(yml, jsn)
|
self.assertEqual(yml, jsn)
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ class JsonYamlResolvedCompareTest(common.HeatTestCase):
|
|||||||
def compare_stacks(self, json_file, yaml_file, parameters):
|
def compare_stacks(self, json_file, yaml_file, parameters):
|
||||||
t1 = self.load_template(json_file)
|
t1 = self.load_template(json_file)
|
||||||
t2 = self.load_template(yaml_file)
|
t2 = self.load_template(yaml_file)
|
||||||
del(t1[u'AWSTemplateFormatVersion'])
|
del t1[u'AWSTemplateFormatVersion']
|
||||||
t1[u'HeatTemplateFormatVersion'] = t2[u'HeatTemplateFormatVersion']
|
t1[u'HeatTemplateFormatVersion'] = t2[u'HeatTemplateFormatVersion']
|
||||||
stack1 = utils.parse_stack(t1, parameters)
|
stack1 = utils.parse_stack(t1, parameters)
|
||||||
stack2 = utils.parse_stack(t2, parameters)
|
stack2 = utils.parse_stack(t2, parameters)
|
||||||
@ -197,10 +197,10 @@ class JsonYamlResolvedCompareTest(common.HeatTestCase):
|
|||||||
# compare resources separately so that resolved static data
|
# compare resources separately so that resolved static data
|
||||||
# is compared
|
# is compared
|
||||||
t1nr = dict(stack1.t.t)
|
t1nr = dict(stack1.t.t)
|
||||||
del(t1nr['Resources'])
|
del t1nr['Resources']
|
||||||
|
|
||||||
t2nr = dict(stack2.t.t)
|
t2nr = dict(stack2.t.t)
|
||||||
del(t2nr['Resources'])
|
del t2nr['Resources']
|
||||||
self.assertEqual(t1nr, t2nr)
|
self.assertEqual(t1nr, t2nr)
|
||||||
|
|
||||||
self.assertEqual(set(stack1), set(stack2))
|
self.assertEqual(set(stack1), set(stack2))
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
# The order of packages is significant, because pip processes them in the order
|
|
||||||
# of appearance. Changing the order has an impact on the overall integration
|
|
||||||
# process, which may cause wedges in the gate later.
|
|
||||||
|
|
||||||
# Hacking already pins down pep8, pyflakes and flake8
|
# Hacking already pins down pep8, pyflakes and flake8
|
||||||
hacking>=3.0.1,<3.1.0 # Apache-2.0
|
hacking>=6.1.0,<6.2.0 # Apache-2.0
|
||||||
# remove this pyflakes from here once you bump the
|
|
||||||
# hacking to 3.2.0 or above. hacking 3.2.0 takes
|
|
||||||
# care of pyflakes version compatibilty.
|
|
||||||
pyflakes>=2.1.1
|
|
||||||
|
|
||||||
bandit!=1.6.0,>=1.1.0 # Apache-2.0
|
bandit!=1.6.0,>=1.1.0 # Apache-2.0
|
||||||
coverage!=4.4,>=4.0 # Apache-2.0
|
coverage!=4.4,>=4.0 # Apache-2.0
|
||||||
|
8
tox.ini
8
tox.ini
@ -132,10 +132,10 @@ import_exceptions = heat.common.i18n
|
|||||||
|
|
||||||
[flake8:local-plugins]
|
[flake8:local-plugins]
|
||||||
extension =
|
extension =
|
||||||
Heat301 = checks:no_log_warn
|
HE301 = checks:no_log_warn
|
||||||
Heat302 = checks:check_python3_no_iteritems
|
HE302 = checks:check_python3_no_iteritems
|
||||||
Heat303 = checks:check_python3_no_iterkeys
|
HE303 = checks:check_python3_no_iterkeys
|
||||||
Heat304 = checks:check_python3_no_itervalues
|
HE304 = checks:check_python3_no_itervalues
|
||||||
paths = ./heat/hacking
|
paths = ./heat/hacking
|
||||||
|
|
||||||
[testenv:debug]
|
[testenv:debug]
|
||||||
|
Loading…
Reference in New Issue
Block a user