localstack/localstack

View on GitHub
localstack-core/localstack/testing/pytest/stepfunctions/utils.py

Summary

Maintainability
D
1 day
Test Coverage

File utils.py has 503 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import logging
import os
from typing import Callable, Final, Optional

Severity: Major
Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.py - About 1 day to fix

    Function create_and_record_logs has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def create_and_record_logs(
    Severity: Major
    Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.py - About 1 hr to fix

      Function create_and_record_events has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def create_and_record_events(
      Severity: Major
      Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.py - About 50 mins to fix

        Function create_and_record_execution has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def create_and_record_execution(
        Severity: Major
        Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.py - About 50 mins to fix

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

          def launch_and_record_logs(
          Severity: Minor
          Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.py - About 45 mins to fix

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

            def create(
            Severity: Minor
            Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.py - About 35 mins to fix

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

              def launch_and_record_execution(
              Severity: Minor
              Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.py - About 35 mins to fix

                Function await_list_execution_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                def await_list_execution_status(
                    stepfunctions_client, state_machine_arn: str, execution_arn: str, status: str
                ):
                    """required as there is some eventual consistency in list_executions vs describe_execution and get_execution_history"""
                
                
                Severity: Minor
                Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.py - About 35 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 _normalise_events has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _normalise_events(events: list[dict]) -> None:
                        start_idx = None
                        sublist = list()
                        in_sublist = False
                        for i, event in enumerate(events):
                Severity: Minor
                Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.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

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

                def await_execution_lists_terminated(
                    stepfunctions_client, state_machine_arn: str, execution_arn: str
                ):
                    def _check_last_is_terminal() -> bool:
                        list_output = stepfunctions_client.list_executions(stateMachineArn=state_machine_arn)
                Severity: Minor
                Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.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

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

                def await_on_execution_logs(
                    aws_client,
                    log_group_name: str,
                    validation_function: Callable[[HistoryEventList], bool] = None,
                ) -> HistoryEventList:
                Severity: Minor
                Found in localstack-core/localstack/testing/pytest/stepfunctions/utils.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