localstack/localstack

View on GitHub
localstack/utils/testutil.py

Summary

Maintainability
F
4 days
Test Coverage

File testutil.py has 583 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import glob
import importlib
import io
import json
import os
Severity: Major
Found in localstack/utils/testutil.py - About 1 day to fix

    Function create_lambda_archive has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_lambda_archive(
        script: str,
        get_content: bool = False,
        libs: List[str] = None,
        runtime: str = None,
    Severity: Minor
    Found in localstack/utils/testutil.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 find_object has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_object(expected_object, object_list):
        for obj in object_list:
            if isinstance(obj, list):
                found = find_object(expected_object, obj)
                if found:
    Severity: Minor
    Found in localstack/utils/testutil.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 find_recursive has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_recursive(key, value, obj):
        if isinstance(obj, dict):
            for k, v in obj.items():
                if k == key and v == value:
                    return True
    Severity: Minor
    Found in localstack/utils/testutil.py - About 2 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 create_lambda_function has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_lambda_function(
        func_name,
        zip_file=None,
        event_source_arn=None,
        handler_file=None,
    Severity: Minor
    Found in localstack/utils/testutil.py - About 2 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 create_lambda_function has 18 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def create_lambda_function(
    Severity: Major
    Found in localstack/utils/testutil.py - About 2 hrs to fix

      Function map_all_s3_objects has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def map_all_s3_objects(
          s3_client, to_json: bool = True, buckets: str | List[str] = None
      ) -> Dict[str, Any]:
          result = {}
          buckets = ensure_list(buckets)
      Severity: Minor
      Found in localstack/utils/testutil.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_lambda_log_events has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_lambda_log_events(
          function_name,
          delay_time=DEFAULT_GET_LOG_EVENTS_DELAY,
          regex_filter: Optional[str] = None,
          log_group=None,
      Severity: Minor
      Found in localstack/utils/testutil.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 create_lambda_api_gateway_integration has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def create_lambda_api_gateway_integration(
      Severity: Major
      Found in localstack/utils/testutil.py - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                if (
                    not raw_message
                    or raw_message.startswith("INIT_START")
                    or raw_message.startswith("START")
                    or raw_message.startswith("END")
        Severity: Critical
        Found in localstack/utils/testutil.py - About 1 hr to fix

          Function connect_api_gateway_to_http_with_lambda_proxy has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def connect_api_gateway_to_http_with_lambda_proxy(
          Severity: Major
          Found in localstack/utils/testutil.py - About 1 hr to fix

            Function create_zip_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def create_zip_file(
                file_path: str,
                zip_file: str = None,
                get_content: bool = False,
                content_root: str = None,
            Severity: Minor
            Found in localstack/utils/testutil.py - About 55 mins 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

            Avoid deeply nested control flow statements.
            Open

                                if os.path.isdir(file_path):
                                    cp_r(file_path, name)
                                else:
                                    shutil.copyfile(file_path, name)
            
            
            Severity: Major
            Found in localstack/utils/testutil.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if not find_recursive(k, v, obj):
                                      all_ok = False
                                      break
                      if all_ok:
              Severity: Major
              Found in localstack/utils/testutil.py - About 45 mins to fix

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

                def create_lambda_archive(
                Severity: Minor
                Found in localstack/utils/testutil.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if exclude_func(relative):
                                          rm_rf(full_name)
                  
                          # create zip file
                          result = create_zip_file(tmp_dir, get_content=get_content)
                  Severity: Major
                  Found in localstack/utils/testutil.py - About 45 mins to fix

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

                    def create_zip_file(
                    Severity: Minor
                    Found in localstack/utils/testutil.py - About 35 mins to fix

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

                      def get_lambda_log_events(
                      Severity: Minor
                      Found in localstack/utils/testutil.py - About 35 mins to fix

                        Function connect_api_gateway_to_http_with_lambda_proxy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def connect_api_gateway_to_http_with_lambda_proxy(
                            gateway_name,
                            target_uri,
                            stage_name=None,
                            methods=None,
                        Severity: Minor
                        Found in localstack/utils/testutil.py - About 25 mins 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

                        There are no issues that match your filters.

                        Category
                        Status