From 554add6004c4c70e0c1a97b1c4078dbfe5ed5ad5 Mon Sep 17 00:00:00 2001 From: Saravanan KR Date: Tue, 31 Oct 2017 13:45:44 +0530 Subject: [PATCH] Refactor the format_validate_parameter fuction to reduce complexity Adding a if condition to format_validate_parameter function, is failing the pep validation, because of complexity is going beyond the 20 limit. Separating the constraints from the base makes it, simpler. Change-Id: Iaa4cdfceea67a17af1e17512cc28eb54dd52907d --- heat/engine/api.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/heat/engine/api.py b/heat/engine/api.py index 3d12d50cd5..c19b4f9f53 100644 --- a/heat/engine/api.py +++ b/heat/engine/api.py @@ -524,6 +524,12 @@ def format_validate_parameter(param): if param.user_value: res[rpc_api.PARAM_VALUE] = param.user_value + _build_parameter_constraints(res, param) + + return res + + +def _build_parameter_constraints(res, param): constraint_description = [] # build constraints @@ -565,8 +571,6 @@ def format_validate_parameter(param): res[rpc_api.PARAM_CONSTRAINT_DESCRIPTION] = " ".join( constraint_description) - return res - def format_software_config(sc, detail=True, include_project=False): if sc is None: