django/django

View on GitHub
django/db/models/expressions.py

Summary

Maintainability
F
1 wk
Test Coverage

File expressions.py has 1628 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import copy
import datetime
import functools
import inspect
from collections import defaultdict
Severity: Major
Found in django/db/models/expressions.py - About 4 days to fix

    BaseExpression has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BaseExpression:
        """Base class for all query expressions."""
    
        empty_result_set_value = NotImplemented
        # aggregate specific fields
    Severity: Minor
    Found in django/db/models/expressions.py - About 4 hrs to fix

      Combinable has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Combinable:
          """
          Provide the ability to combine one or two objects with
          some connector. For example F('foo') + F('bar').
          """
      Severity: Minor
      Found in django/db/models/expressions.py - About 3 hrs to fix

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

            def convert_value(self):
                """
                Expressions provide their own converters because users have the option
                of manually specifying the output_field which may be a different type
                from the one the database returns.
        Severity: Minor
        Found in django/db/models/expressions.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 resolve_expression has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def resolve_expression(
                self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False
            ):
                lhs = self.lhs.resolve_expression(
                    query, allow_joins, reuse, summarize, for_save
        Severity: Minor
        Found in django/db/models/expressions.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 identity has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def identity(self):
                args, kwargs = self._constructor_args
                signature = self._constructor_signature.bind_partial(self, *args, **kwargs)
                signature.apply_defaults()
                arguments = iter(signature.arguments.items())
        Severity: Minor
        Found in django/db/models/expressions.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 as_sql has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def as_sql(
        Severity: Major
        Found in django/db/models/expressions.py - About 50 mins to fix

          Function resolve_expression has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def resolve_expression(
          Severity: Minor
          Found in django/db/models/expressions.py - About 45 mins to fix

            Function as_sql has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def as_sql(
            Severity: Minor
            Found in django/db/models/expressions.py - About 45 mins to fix

              Function resolve_expression has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def resolve_expression(
              Severity: Minor
              Found in django/db/models/expressions.py - About 45 mins to fix

                Function resolve_expression has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def resolve_expression(
                Severity: Minor
                Found in django/db/models/expressions.py - About 45 mins to fix

                  Function resolve_expression has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def resolve_expression(
                  Severity: Minor
                  Found in django/db/models/expressions.py - About 45 mins to fix

                    Function resolve_expression has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def resolve_expression(
                    Severity: Minor
                    Found in django/db/models/expressions.py - About 45 mins to fix

                      Function resolve_expression has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def resolve_expression(
                      Severity: Minor
                      Found in django/db/models/expressions.py - About 45 mins to fix

                        Function resolve_expression has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def resolve_expression(
                        Severity: Minor
                        Found in django/db/models/expressions.py - About 45 mins to fix

                          Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def __init__(
                          Severity: Minor
                          Found in django/db/models/expressions.py - About 45 mins to fix

                            Function resolve_expression has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def resolve_expression(
                            Severity: Minor
                            Found in django/db/models/expressions.py - About 45 mins to fix

                              Function resolve_expression has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def resolve_expression(
                              Severity: Minor
                              Found in django/db/models/expressions.py - About 45 mins to fix

                                Function resolve_expression has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def resolve_expression(
                                Severity: Minor
                                Found in django/db/models/expressions.py - About 45 mins to fix

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

                                      def resolve_expression(
                                  Severity: Minor
                                  Found in django/db/models/expressions.py - About 35 mins to fix

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

                                        def as_sql(self, compiler, connection, template=None, **extra_context):
                                    Severity: Minor
                                    Found in django/db/models/expressions.py - About 35 mins to fix

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

                                          def __init__(self, *cases, default=None, output_field=None, **extra):
                                      Severity: Minor
                                      Found in django/db/models/expressions.py - About 35 mins to fix

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

                                            def as_sql(self, compiler, connection, template=None, **extra_context):
                                        Severity: Minor
                                        Found in django/db/models/expressions.py - About 35 mins to fix

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

                                              def as_sql(self, compiler, connection, template=None, **extra_context):
                                          Severity: Minor
                                          Found in django/db/models/expressions.py - About 35 mins to fix

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

                                                def __init__(self, expression, descending=False, nulls_first=None, nulls_last=None):
                                            Severity: Minor
                                            Found in django/db/models/expressions.py - About 35 mins to fix

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

                                                  def as_sqlite(self, compiler, connection, **extra_context):
                                                      sql, params = self.as_sql(compiler, connection, **extra_context)
                                                      if self.connector in {Combinable.MUL, Combinable.DIV}:
                                                          try:
                                                              lhs_type = self.lhs.output_field.get_internal_type()
                                              Severity: Minor
                                              Found in django/db/models/expressions.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

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

                                                  def flatten(self):
                                                      """
                                                      Recursively yield this expression and all subexpressions, in
                                                      depth-first order.
                                                      """
                                              Severity: Minor
                                              Found in django/db/models/expressions.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

                                              Function _resolve_output_field has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  def _resolve_output_field(self):
                                                      """
                                                      Attempt to infer the output type of the expression.
                                              
                                                      As a guess, if the output fields of all source fields match then simply
                                              Severity: Minor
                                              Found in django/db/models/expressions.py - About 25 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