airbnb/caravel

View on GitHub
superset/sql/parse.py

Summary

Maintainability
D
1 day
Test Coverage

File parse.py has 537 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/sql/parse.py - About 1 day to fix

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

    def split_kql(kql: str) -> list[str]:
        """
        Custom function for splitting KQL statements.
        """
        statements = []
    Severity: Minor
    Found in superset/sql/parse.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

    Consider simplifying this complex logical expression.
    Open

            if state == KQLSplitState.OUTSIDE_STRING:
                if character == ";":
                    statements.append(script[statement_start:i])
                    statement_start = i + 1
                elif character == "'":
    Severity: Major
    Found in superset/sql/parse.py - About 1 hr to fix

      Function extract_tables_from_statement has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def extract_tables_from_statement(
          statement: exp.Expression,
          dialect: Dialects | None,
      ) -> set[Table]:
          """
      Severity: Minor
      Found in superset/sql/parse.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 is_mutating has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def is_mutating(self) -> bool:
              """
              Check if the statement mutates data (DDL/DML).
      
              :return: True if the statement mutates data.
      Severity: Minor
      Found in superset/sql/parse.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 split_script has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def split_script(
              cls,
              script: str,
              engine: str,
          ) -> list[SQLStatement]:
      Severity: Minor
      Found in superset/sql/parse.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

      There are no issues that match your filters.

      Category
      Status