localstack/localstack

View on GitHub
localstack/services/cloudformation/engine/template_deployer.py

Summary

Maintainability
F
1 wk
Test Coverage

File template_deployer.py has 1237 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import base64
import json
import logging
import re
import traceback
Severity: Major
Found in localstack/services/cloudformation/engine/template_deployer.py - About 3 days to fix

    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,
    Severity: Minor
    Found in localstack/services/cloudformation/engine/template_deployer.py - About 1 day to fix

    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,
    Severity: Minor
    Found in localstack/services/cloudformation/engine/template_deployer.py - About 4 hrs to fix

    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,
    Severity: Minor
    Found in localstack/services/cloudformation/engine/template_deployer.py - About 4 hrs to fix

    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 delete_stack has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def delete_stack(self):
            if not self.stack:
                return
            self.stack.set_stack_status("DELETE_IN_PROGRESS")
            stack_resources = list(self.stack.resources.values())
    Severity: Minor
    Found in localstack/services/cloudformation/engine/template_deployer.py - About 3 hrs to fix

    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 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,
    Severity: Minor
    Found in localstack/services/cloudformation/engine/template_deployer.py - About 1 hr to fix

    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
    Severity: Minor
    Found in localstack/services/cloudformation/engine/template_deployer.py - About 1 hr to fix

    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 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def resolve_refs_recursively(
    Severity: Major
    Found in localstack/services/cloudformation/engine/template_deployer.py - About 1 hr to fix

      Function _resolve_refs_recursively has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _resolve_refs_recursively(
      Severity: Major
      Found in localstack/services/cloudformation/engine/template_deployer.py - About 1 hr to fix

        Function construct_changes has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def construct_changes(
        Severity: Major
        Found in localstack/services/cloudformation/engine/template_deployer.py - About 1 hr to fix

          Function resolve_placeholders_in_string has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def resolve_placeholders_in_string(
          Severity: Major
          Found in localstack/services/cloudformation/engine/template_deployer.py - About 1 hr to fix

            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}.",
                                    )
            Severity: Major
            Found in localstack/services/cloudformation/engine/template_deployer.py - About 45 mins to fix

              Function resolve_ref has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def resolve_ref(
              Severity: Minor
              Found in localstack/services/cloudformation/engine/template_deployer.py - About 45 mins to fix

                Function apply_changes has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def apply_changes(
                Severity: Minor
                Found in localstack/services/cloudformation/engine/template_deployer.py - About 45 mins to fix

                  Function prepare_should_deploy_change has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def prepare_should_deploy_change(
                  Severity: Minor
                  Found in localstack/services/cloudformation/engine/template_deployer.py - About 35 mins to fix

                    Function apply_changes_in_loop has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def apply_changes_in_loop(
                    Severity: Minor
                    Found in localstack/services/cloudformation/engine/template_deployer.py - About 35 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return result
                      Severity: Major
                      Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return result
                        Severity: Major
                        Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                          return values[index]
                          Severity: Major
                          Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return azs
                            Severity: Major
                            Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return attribute_candidate
                              Severity: Major
                              Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return selected_map.get(first_level_attribute).get(second_level_attribute)
                                Severity: Major
                                Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                  return values[int(index)]
                                  Severity: Major
                                  Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return PLACEHOLDER_AWS_NO_VALUE
                                    Severity: Major
                                    Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                  return fn_equals_type_conversion(operand1) == fn_equals_type_conversion(operand2)
                                      Severity: Major
                                      Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                    return [p.strip() for p in parameter_value.split(",")]
                                        Severity: Major
                                        Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                              return resources[ref].get("PhysicalResourceId")
                                          Severity: Major
                                          Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                                return secret_value
                                            Severity: Major
                                            Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                          return string.split(delimiter)
                                              Severity: Major
                                              Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return account_id
                                                Severity: Major
                                                Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                              return conditions[value[keys_list[0]]]
                                                  Severity: Major
                                                  Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                            return AWS_URL_SUFFIX
                                                    Severity: Major
                                                    Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                                      return resolve_refs_recursively(
                                                      Severity: Major
                                                      Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                    return stack_export["Value"]
                                                        Severity: Major
                                                        Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                          return None
                                                          Severity: Major
                                                          Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                        return result
                                                            Severity: Major
                                                            Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                          return to_str(base64.b64encode(to_bytes(value_to_encode)))
                                                              Severity: Major
                                                              Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                        return {}
                                                                Severity: Major
                                                                Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                      return value
                                                                  Severity: Major
                                                                  Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                            return match.group(0)
                                                                    Severity: Major
                                                                    Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

                                                                                  return parameter_value
                                                                      Severity: Major
                                                                      Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                                        Avoid too many return statements within this function.
                                                                        Open

                                                                                    return not condition
                                                                        Severity: Major
                                                                        Found in localstack/services/cloudformation/engine/template_deployer.py - About 30 mins to fix

                                                                          There are no issues that match your filters.

                                                                          Category
                                                                          Status