airbnb/caravel

View on GitHub
superset/tasks/utils.py

Summary

Maintainability
D
1 day
Test Coverage

Function get_executor has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

def get_executor(
    executor_types: list[ExecutorType],
    model: Dashboard | ReportSchedule | Slice,
    current_user: str | None = None,
) -> tuple[ExecutorType, str]:
Severity: Minor
Found in superset/tasks/utils.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 fetch_csrf_token has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def fetch_csrf_token(
    headers: dict[str, str], session_cookie_name: str = "session"
) -> dict[str, str]:
    """
    Fetches a CSRF token for API requests
Severity: Minor
Found in superset/tasks/utils.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 creator and (user := owner_dict.get(creator.id)):
                        return executor_type, user.username
                return executor_type, owners[0].username
Severity: Major
Found in superset/tasks/utils.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if modifier and (user := owner_dict.get(modifier.id)):
                            return executor_type, user.username
                    if creator := model.created_by:
    Severity: Major
    Found in superset/tasks/utils.py - About 45 mins to fix

      Avoid too many return statements within this function.
      Open

                              return executor_type, user.username
      Severity: Major
      Found in superset/tasks/utils.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return executor_type, owner.username
        Severity: Major
        Found in superset/tasks/utils.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                                  return executor_type, user.username
          Severity: Major
          Found in superset/tasks/utils.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return executor_type, owners[0].username
            Severity: Major
            Found in superset/tasks/utils.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return executor_type, owners[0].username
              Severity: Major
              Found in superset/tasks/utils.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return executor_type, user.username
                Severity: Major
                Found in superset/tasks/utils.py - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status