airbnb/caravel

View on GitHub
superset/views/utils.py

Summary

Maintainability
D
2 days
Test Coverage

Function build_extra_filters has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

def build_extra_filters(  # pylint: disable=too-many-locals,too-many-nested-blocks
    layout: dict[str, dict[str, Any]],
    filter_scopes: dict[str, dict[str, Any]],
    default_filters: dict[str, dict[str, list[Any]]],
    slice_id: int,
Severity: Minor
Found in superset/views/utils.py - About 6 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

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

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
Severity: Minor
Found in superset/views/utils.py - About 6 hrs to fix

    Function get_form_data has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_form_data(
        slice_id: Optional[int] = None,
        use_slice_data: bool = False,
        initial_form_data: Optional[dict[str, Any]] = None,
    ) -> tuple[dict[str, Any], Optional[Slice]]:
    Severity: Minor
    Found in superset/views/utils.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 add_sqllab_custom_filters has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_sqllab_custom_filters(form_data: dict[Any, Any]) -> Any:
        """
        SQLLab can include a "filters" attribute in the templateParams.
        The filters attribute is a list of filters to include in the
        request. Useful for testing templates in SQLLab.
    Severity: Minor
    Found in superset/views/utils.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 _deserialize_results_payload has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def _deserialize_results_payload(
        payload: Union[bytes, str], query: Query, use_msgpack: Optional[bool] = False
    ) -> dict[str, Any]:
        logger.debug("Deserializing from msgpack: %r", use_msgpack)
        if use_msgpack:
    Severity: Minor
    Found in superset/views/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

                        for filter_config in filter_configs:
                            if filter_config["column"] == col:
                                is_multiple = filter_config["multiple"]
    
                                if not is_multiple and isinstance(val, list):
    Severity: Major
    Found in superset/views/utils.py - About 45 mins to fix

      Function get_permissions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_permissions(
          user: User,
      ) -> tuple[dict[str, list[tuple[str]]], DefaultDict[str, list[str]]]:
          if not user.roles:
              raise AttributeError("User object does not have roles")
      Severity: Minor
      Found in superset/views/utils.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 get_viz has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def get_viz(
      Severity: Minor
      Found in superset/views/utils.py - About 35 mins to fix

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

        def build_extra_filters(  # pylint: disable=too-many-locals,too-many-nested-blocks
        Severity: Minor
        Found in superset/views/utils.py - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status