airbnb/caravel

View on GitHub
superset/charts/data/api.py

Summary

Maintainability
D
1 day
Test Coverage

File api.py has 381 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/charts/data/api.py - About 5 hrs to fix

    Function _send_chart_response has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _send_chart_response(
            self,
            result: dict[Any, Any],
            form_data: dict[str, Any] | None = None,
            datasource: BaseDatasource | Query | None = None,
    Severity: Minor
    Found in superset/charts/data/api.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_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_data(self, pk: int) -> Response:
            """
            Take a chart ID and uses the query context stored when the chart was saved
            to return payload data response.
            ---
    Severity: Minor
    Found in superset/charts/data/api.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 data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def data(self) -> Response:
            """
            Take a query context constructed in the client and return payload
            data response for the given query
            ---
    Severity: Minor
    Found in superset/charts/data/api.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 _get_data_response has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _get_data_response(
    Severity: Minor
    Found in superset/charts/data/api.py - About 35 mins to fix

      Avoid too many return statements within this function.
      Open

                  return Response(
      Severity: Major
      Found in superset/charts/data/api.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return self._run_async(json_body, command)
        Severity: Major
        Found in superset/charts/data/api.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return self.response_400(message=f"Unsupported result_format: {result_format}")
          Severity: Major
          Found in superset/charts/data/api.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return self._get_data_response(
            Severity: Major
            Found in superset/charts/data/api.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return self._run_async(json_body, command)
              Severity: Major
              Found in superset/charts/data/api.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return self._get_data_response(
                Severity: Major
                Found in superset/charts/data/api.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return resp
                  Severity: Major
                  Found in superset/charts/data/api.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return self.response_400(
                    Severity: Major
                    Found in superset/charts/data/api.py - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status