atlassian/localstack

View on GitHub
localstack/utils/testutil.py

Summary

Maintainability
C
1 day
Test Coverage

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 iteritems(obj):
            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

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

    def create_lambda_archive(script, stream=None, get_content=False, libs=[], runtime=None):
        """Utility method to create a Lambda function archive"""
        tmp_dir = tempfile.mkdtemp(prefix=ARCHIVE_DIR_PREFIX)
        TMP_FILES.append(tmp_dir)
        file_name = get_handler_file_from_name(LAMBDA_DEFAULT_HANDLER, runtime=runtime)
    Severity: Minor
    Found in localstack/utils/testutil.py - About 45 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

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

    def create_lambda_function(func_name, zip_file, event_source_arn=None, handler=LAMBDA_DEFAULT_HANDLER,
    Severity: Minor
    Found in localstack/utils/testutil.py - About 45 mins to fix

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

      def create_lambda_archive(script, stream=None, get_content=False, libs=[], runtime=None):
      Severity: Minor
      Found in localstack/utils/testutil.py - About 35 mins to fix

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

        def map_all_s3_objects(to_json=True):
            s3_client = get_s3_client()
            result = {}
            for bucket in s3_client.buckets.all():
                for key in bucket.objects.all():
        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