airbnb/superset

View on GitHub
superset/db_engine_specs/presto.py

Summary

Maintainability
F
6 days
Test Coverage

File presto.py has 1132 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: Major
Found in superset/db_engine_specs/presto.py - About 2 days to fix

    Function _parse_structural_column has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

        def _parse_structural_column(  # pylint: disable=too-many-locals
            cls,
            parent_column_name: str,
            parent_data_type: str,
            result: list[ResultSetColumnType],
    Severity: Minor
    Found in superset/db_engine_specs/presto.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

    Function expand_data has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        def expand_data(  # pylint: disable=too-many-locals
            cls, columns: list[ResultSetColumnType], data: list[dict[Any, Any]]
        ) -> tuple[
            list[ResultSetColumnType], list[dict[Any, Any]], list[ResultSetColumnType]
        ]:
    Severity: Minor
    Found in superset/db_engine_specs/presto.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

    PrestoEngineSpec has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PrestoEngineSpec(PrestoBaseEngineSpec):
        engine = "presto"
        engine_name = "Presto"
        allows_alias_to_source_column = False
    
    
    Severity: Minor
    Found in superset/db_engine_specs/presto.py - About 2 hrs to fix

      Function _partition_query has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def _partition_query(  # pylint: disable=too-many-arguments,too-many-locals,unused-argument
              cls,
              table: Table,
              indexes: list[dict[str, Any]],
              database: Database,
      Severity: Minor
      Found in superset/db_engine_specs/presto.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 handle_cursor has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_cursor(cls, cursor: Cursor, query: Query) -> None:
              """Updates progress information"""
              if tracking_url := cls.get_tracking_url(cursor):
                  query.tracking_url = tracking_url
                  db.session.commit()
      Severity: Minor
      Found in superset/db_engine_specs/presto.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 select_star has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def select_star(  # pylint: disable=too-many-arguments
      Severity: Major
      Found in superset/db_engine_specs/presto.py - About 1 hr to fix

        Function query_cost_formatter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def query_cost_formatter(
                cls, raw_cost: list[dict[str, Any]]
            ) -> list[dict[str, str]]:
                """
                Format cost estimate.
        Severity: Minor
        Found in superset/db_engine_specs/presto.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_children has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_children(column: ResultSetColumnType) -> list[ResultSetColumnType]:
            """
            Get the children of a complex Presto type (row or array).
        
            For arrays, we return a single list with the base type:
        Severity: Minor
        Found in superset/db_engine_specs/presto.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_columns has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_columns(
                cls,
                inspector: Inspector,
                table: Table,
                options: dict[str, Any] | None = None,
        Severity: Minor
        Found in superset/db_engine_specs/presto.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

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

            def _partition_query(  # pylint: disable=too-many-arguments,too-many-locals,unused-argument
        Severity: Major
        Found in superset/db_engine_specs/presto.py - About 50 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if column_type is None:
                                      column_type = types.String()
                                      logger.info(
                                          "Did not recognize type %s of column %s",
                                          field_info[1],
          Severity: Major
          Found in superset/db_engine_specs/presto.py - About 45 mins to fix

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

                def latest_sub_partition(
                    cls,
                    database: Database,
                    table: Table,
                    **kwargs: Any,
            Severity: Minor
            Found in superset/db_engine_specs/presto.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

            Avoid deeply nested control flow statements.
            Open

                                    if field_info[1] == "array" or field_info[1] == "row":
                                        stack.append((field_info[0], field_info[1]))
                                        full_parent_path = cls._get_full_name(stack)
                                        result.append(
                                            cls._create_column_info(full_parent_path, column_type)
            Severity: Major
            Found in superset/db_engine_specs/presto.py - About 45 mins to fix

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

                  def _get_fields(cls, cols: list[ResultSetColumnType]) -> list[ColumnClause]:
                      """
                      Format column clauses where names are in quotes and labels are specified
                      :param cols: columns
                      :return: column clauses
              Severity: Minor
              Found in superset/db_engine_specs/presto.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

              Avoid deeply nested control flow statements.
              Open

                                      if not single_field:
                                          continue
                                      # split on whitespace to get field name and data type
                                      field_info = cls._split_data_type(single_field, r"\s")
              Severity: Major
              Found in superset/db_engine_specs/presto.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        for _ in range(missing):
                                            data.insert(i + current_unnested_rows + 1, {})
                                            unnested_rows[i] += 1
                
                                        # unnest array into rows
                Severity: Major
                Found in superset/db_engine_specs/presto.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for j, value in enumerate(values):
                                              data[i + j][name] = value
                  
                                          # skip newly unnested rows
                                          i += unnested_rows[i]
                  Severity: Major
                  Found in superset/db_engine_specs/presto.py - About 45 mins to fix

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

                        def where_latest_partition(
                            cls,
                            database: Database,
                            table: Table,
                            query: Select,
                    Severity: Minor
                    Found in superset/db_engine_specs/presto.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

                    There are no issues that match your filters.

                    Category
                    Status