airbnb/caravel

View on GitHub
superset/utils/log.py

Summary

Maintainability
D
1 day
Test Coverage

File log.py has 344 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/utils/log.py - About 4 hrs to fix

    Function log_with_context has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def log_with_context(  # pylint: disable=too-many-locals,too-many-arguments
            self,
            action: str,
            duration: timedelta | None = None,
            object_ref: str | None = None,
    Severity: Minor
    Found in superset/utils/log.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 log has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def log(  # pylint: disable=too-many-arguments
    Severity: Major
    Found in superset/utils/log.py - About 1 hr to fix

      Function log has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def log(  # pylint: disable=too-many-arguments
      Severity: Major
      Found in superset/utils/log.py - About 1 hr to fix

        Function _wrapper has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _wrapper(
                self,
                f: Callable[..., Any],
                action: str | Callable[..., str] | None = None,
                object_ref: str | Callable[..., str] | Literal[False] | None = None,
        Severity: Minor
        Found in superset/utils/log.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 log has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def log(  # pylint: disable=too-many-arguments,too-many-locals
        Severity: Major
        Found in superset/utils/log.py - About 1 hr to fix

          Function log_with_context has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def log_with_context(  # pylint: disable=too-many-locals,too-many-arguments
          Severity: Major
          Found in superset/utils/log.py - About 50 mins to fix

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

                def __call__(
            Severity: Minor
            Found in superset/utils/log.py - About 35 mins to fix

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

                  def _wrapper(
              Severity: Minor
              Found in superset/utils/log.py - About 35 mins to fix

                Function collect_request_payload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                def collect_request_payload() -> dict[str, Any]:
                    """Collect log payload identifiable from request context"""
                    if not request:
                        return {}
                
                
                Severity: Minor
                Found in superset/utils/log.py - About 35 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