airbnb/caravel

View on GitHub
superset/db_engine_specs/base.py

Summary

Maintainability
F
1 wk
Test Coverage

File base.py has 1989 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/base.py - About 5 days to fix

    BaseEngineSpec has 91 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BaseEngineSpec:  # pylint: disable=too-many-public-methods
        """Abstract class for database engine specific configurations
    
        Attributes:
            allows_alias_to_source_column: Whether the engine is able to pick the
    Severity: Major
    Found in superset/db_engine_specs/base.py - About 1 day to fix

      Function apply_top_to_sql has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def apply_top_to_sql(cls, sql: str, limit: int) -> str:
              """
              Alters the SQL statement to apply a TOP clause
              :param limit: Maximum number of rows to be returned by the query
              :param sql: SQL query
      Severity: Minor
      Found in superset/db_engine_specs/base.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 get_timestamp_expr has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_timestamp_expr(
              cls,
              col: ColumnClause,
              pdf: str | None,
              time_grain: str | None,
      Severity: Minor
      Found in superset/db_engine_specs/base.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 select_star has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def select_star(  # pylint: disable=too-many-arguments,too-many-locals
              cls,
              database: Database,
              table: Table,
              engine: Engine,
      Severity: Minor
      Found in superset/db_engine_specs/base.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 fetch_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def fetch_data(cls, cursor: Any, limit: int | None = None) -> list[tuple[Any, ...]]:
              """
      
              :param cursor: Cursor instance
              :param limit: Maximum number of rows to be returned by the cursor
      Severity: Minor
      Found in superset/db_engine_specs/base.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,too-many-locals
      Severity: Major
      Found in superset/db_engine_specs/base.py - About 1 hr to fix

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

            def _sort_time_grains(
                cls, val: tuple[str | None, str], index: int
            ) -> float | int | str:
                """
                Return an ordered time-based value of a portion of a time grain
        Severity: Minor
        Found in superset/db_engine_specs/base.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 estimate_query_cost has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def estimate_query_cost(  # pylint: disable=too-many-arguments
        Severity: Minor
        Found in superset/db_engine_specs/base.py - About 45 mins to fix

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

              def validate_parameters(
                  cls, properties: BasicPropertiesType
              ) -> list[SupersetError]:
                  """
                  Validates any number of parameters, for progressive validation.
          Severity: Minor
          Found in superset/db_engine_specs/base.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 adjust_engine_params has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def adjust_engine_params(  # pylint: disable=unused-argument
          Severity: Minor
          Found in superset/db_engine_specs/base.py - About 35 mins to fix

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

                def where_latest_partition(  # pylint: disable=unused-argument
            Severity: Minor
            Found in superset/db_engine_specs/base.py - About 35 mins to fix

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

                  def execute(  # pylint: disable=unused-argument
              Severity: Minor
              Found in superset/db_engine_specs/base.py - About 35 mins to fix

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

                    def get_url_for_impersonation(
                Severity: Minor
                Found in superset/db_engine_specs/base.py - About 35 mins to fix

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

                      def execute(  # pylint: disable=unused-argument
                          cls,
                          cursor: Any,
                          query: str,
                          database: Database,
                  Severity: Minor
                  Found in superset/db_engine_specs/base.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 get_column_types has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_column_types(
                          cls,
                          column_type: str | None,
                      ) -> tuple[TypeEngine, GenericDataType] | None:
                          """
                  Severity: Minor
                  Found in superset/db_engine_specs/base.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