superset/migrations/shared/native_filters.py
Function convert_filter_scopes_to_native_filters
has a Cognitive Complexity of 135 (exceeds 5 allowed). Consider refactoring. Open
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]]:
- Read upRead up
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
Open
def migrate_dashboard(dashboard: Dashboard) -> None:
"""
Convert the dashboard to use native filters.
:param dashboard: The dashboard to convert
- Read upRead up
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
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
Avoid deeply nested control flow statements. Open
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.
Avoid deeply nested control flow statements. Open
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"]
Avoid deeply nested control flow statements. Open
Open
if config["column"] == field:
fltr.update(
{
"controlValues": {
"defaultToFirstItem": False,