airbnb/superset

View on GitHub
superset/migrations/shared/native_filters.py

Summary

Maintainability
F
3 days
Test Coverage

Function convert_filter_scopes_to_native_filters has a Cognitive Complexity of 135 (exceeds 5 allowed). Consider refactoring.
Open

def convert_filter_scopes_to_native_filters(  # pylint: disable=invalid-name,too-many-branches,too-many-locals,too-many-nested-blocks,too-many-statements
    json_metadata: dict[str, Any],
    position_json: dict[str, Any],
    filter_boxes: list[Slice],
) -> list[dict[str, Any]]:
Severity: Minor
Found in superset/migrations/shared/native_filters.py - About 2 days 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 migrate_dashboard has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

def migrate_dashboard(dashboard: Dashboard) -> None:
    """
    Convert the dashboard to use native filters.

    :param dashboard: The dashboard to convert
Severity: Minor
Found in superset/migrations/shared/native_filters.py - About 4 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 native_filters.py has 275 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/migrations/shared/native_filters.py - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                            for idx, key in enumerate(value[relation]):
                                if key in mapping:
                                    value[relation][idx] = mapping[key]
    
            # Remove the filter-box charts from the dashboard/slice mapping.
    Severity: Major
    Found in superset/migrations/shared/native_filters.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if child["filterType"] == "filter_select":
                              for parent in filter_by_key_and_field[str(other.id)].values():
                                  if (
                                      parent["filterType"] in {"filter_select", "filter_time"}
                                      and parent["id"] not in child["cascadeParentIds"]
      Severity: Major
      Found in superset/migrations/shared/native_filters.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if config["column"] == field:
                                fltr.update(
                                    {
                                        "controlValues": {
                                            "defaultToFirstItem": False,
        Severity: Major
        Found in superset/migrations/shared/native_filters.py - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status