From: Ezhilarasi Date: Thu, 26 Sep 2019 11:47:50 +0000 (+0530) Subject: Sonarfix: Reduce cognitive complexity X-Git-Tag: 6.0.0~35^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;ds=sidebyside;h=800b9dc706ded01d69b3ffd2fbf8b816b4c0a6db;hp=1d319a416ba8f0cb764d86323f78318b0d3a8f4c;p=vvp%2Fvalidation-scripts.git Sonarfix: Reduce cognitive complexity Reduced cognitive complexity in validate_metadata method Change-Id: I195971985214f54a44c56a2e425825251a91c83b Issue-ID: VVP-294 Signed-off-by: Ezhilarasi --- diff --git a/ice_validator/tests/test_nova_servers_workload_context.py b/ice_validator/tests/test_nova_servers_workload_context.py index 4c2ec10..dc4c437 100644 --- a/ice_validator/tests/test_nova_servers_workload_context.py +++ b/ice_validator/tests/test_nova_servers_workload_context.py @@ -43,7 +43,7 @@ import pytest from tests import cached_yaml as yaml -from .helpers import validates +from .helpers import validates, get_param VERSION = "1.0.0" @@ -89,16 +89,7 @@ def validate_metadata(metadata, parameters): Return error message string or None if no errors. """ for value in metadata.values(): - if isinstance(value, dict): - if "get_param" in value: - if value["get_param"] == "workload_context": - wc = parameters.get("workload_context", {}) - if wc.get("type") == "string": - break - else: - return ( - 'must have parameter "workload_context"' ' of type "string"' - ) - break - else: - return None + if get_param(value) == "workload_context" and parameters.get("workload_context", {}).get("type", "") != "string": + return 'must have parameter "workload_context" of type "string"' + else: + return None