File template_deployer.py
has 1387 lines of code (exceeds 250 allowed). Consider refactoring. Open
import base64
import json
import logging
import re
import traceback
Function _resolve_refs_recursively
has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring. Open
def _resolve_refs_recursively(
account_id: str,
region_name: str,
stack_name: str,
resources: dict,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function resolve_refs_recursively
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def resolve_refs_recursively(
account_id: str,
region_name: str,
stack_name: str,
resources: dict,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function resolve_placeholders_in_string
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def resolve_placeholders_in_string(
account_id: str,
region_name: str,
result,
stack_name: str,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
TemplateDeployerBase
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class TemplateDeployerBase(ABC):
def __init__(self, account_id: str, region_name: str, stack):
self.stack = stack
self.account_id = account_id
self.region_name = region_name
Function resolve_ref
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def resolve_ref(
account_id: str,
region_name: str,
stack_name: str,
resources: dict,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function apply_changes_in_loop
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def apply_changes_in_loop(
self,
changes: list[ChangeConfig],
stack: Stack,
action: Optional[str] = None,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_attr_from_model_instance
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_attr_from_model_instance(
resource: dict, attribute_name: str, resource_type: str, resource_id: str
) -> str:
properties = resource.get("Properties", {})
# if there's no entry in VALID_GETATT_PROPERTIES for the resource type we still default to "open" and accept anything
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function construct_changes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def construct_changes(
self,
existing_stack,
new_stack,
# TODO: remove initialize argument from here, and determine action based on resource status
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function resolve_placeholders_in_string
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_placeholders_in_string(
Function _resolve_refs_recursively
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def _resolve_refs_recursively(
Function resolve_refs_recursively
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_refs_recursively(
Function construct_changes
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def construct_changes(
Avoid deeply nested control flow statements. Open
if json_key not in json_secret:
raise DependencyNotYetSatisfied(
resource_ids=secret_id,
message=f"Key {json_key} is not yet available in secret {secret_id}.",
)
Function get_unsatisfied_dependencies_for_resources
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_unsatisfied_dependencies_for_resources(
self, resources, depending_resource=None, return_first=True
):
result = {}
for resource_id, resource in resources.items():
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function resolve_ref
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_ref(
Function apply_changes
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def apply_changes(
Function apply_changes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def apply_changes(
self,
existing_stack: Stack,
new_stack: StackChangeSet,
change_set_id: Optional[str] = None,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function resource_config_differs
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def resource_config_differs(self, resource_new):
"""Return whether the given resource properties differ from the existing config (for stack updates)."""
# TODO: this is broken for default fields and result_handler property modifications when they're added to the properties in the model
resource_id = resource_new["LogicalResourceId"]
resource_old = self.resources[resource_id]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function prepare_should_deploy_change
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def prepare_should_deploy_change(
self, resource_id: str, change: ResourceChange, stack, new_resources: dict
) -> bool:
"""
TODO: document
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return values[index]
Avoid too many return
statements within this function. Open
return [p.strip() for p in parameter_value.split(",")]
Avoid too many return
statements within this function. Open
return string.split(delimiter)
Avoid too many return
statements within this function. Open
return value
Avoid too many return
statements within this function. Open
return PLACEHOLDER_AWS_NO_VALUE
Avoid too many return
statements within this function. Open
return AWS_URL_SUFFIX
Avoid too many return
statements within this function. Open
return result
Avoid too many return
statements within this function. Open
return selected_map.get(first_level_attribute).get(second_level_attribute)
Avoid too many return
statements within this function. Open
return fn_equals_type_conversion(operand1) == fn_equals_type_conversion(operand2)
Avoid too many return
statements within this function. Open
return conditions[value[keys_list[0]]]
Avoid too many return
statements within this function. Open
return result
Avoid too many return
statements within this function. Open
return to_str(base64.b64encode(to_bytes(value_to_encode)))
Avoid too many return
statements within this function. Open
return match.group(0)
Avoid too many return
statements within this function. Open
return resolve_refs_recursively(
Avoid too many return
statements within this function. Open
return attribute_candidate
Avoid too many return
statements within this function. Open
return result
Avoid too many return
statements within this function. Open
return account_id
Avoid too many return
statements within this function. Open
return secret_value
Avoid too many return
statements within this function. Open
return values[int(index)]
Avoid too many return
statements within this function. Open
return parameter_value
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return None
Avoid too many return
statements within this function. Open
return {}
Avoid too many return
statements within this function. Open
return resources[ref].get("PhysicalResourceId")
Avoid too many return
statements within this function. Open
return stack_export["Value"]
Avoid too many return
statements within this function. Open
return not condition
Avoid too many return
statements within this function. Open
return azs