django/django

View on GitHub
django/db/models/sql/query.py

Summary

Maintainability
F
2 wks
Test Coverage

File query.py has 1885 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Create SQL statements for QuerySets.

The code in here encapsulates all of the SQL construction so that QuerySets
themselves do not have to (and could be backed by things other than SQL
Severity: Major
Found in django/db/models/sql/query.py - About 5 days to fix

    Query has 90 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Query(BaseExpression):
        """A single SQL query."""
    
        alias_prefix = 'T'
        subq_aliases = frozenset([alias_prefix])
    Severity: Major
    Found in django/db/models/sql/query.py - About 1 day to fix

      Function names_to_path has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
      Open

          def names_to_path(self, names, opts, allow_many=True, fail_on_missing=False):
              """
              Walk the list of names and turns them into PathInfo tuples. A single
              name in 'names' can generate multiple PathInfos (m2m, for example).
      
      
      Severity: Minor
      Found in django/db/models/sql/query.py - About 1 day 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 deferred_to_data has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
      Open

          def deferred_to_data(self, target, callback):
              """
              Convert the self.deferred_loading data structure to an alternate data
              structure, describing the field that *will* be loaded. This is used to
              compute the columns to select from the database and also by the
      Severity: Minor
      Found in django/db/models/sql/query.py - About 7 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

      Function build_filter has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_filter(self, filter_expr, branch_negated=False, current_negated=False,
                           can_reuse=None, allow_joins=True, split_subq=True,
                           reuse_with_filtered_relation=False, check_filterable=True):
              """
              Build a WhereNode for a single filter clause but don't add it
      Severity: Minor
      Found in django/db/models/sql/query.py - About 5 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

      Function setup_joins has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          def setup_joins(self, names, opts, alias, can_reuse=None, allow_many=True,
                          reuse_with_filtered_relation=False):
              """
              Compute the necessary table joins for the passage through the fields
              given in 'names'. 'opts' is the Options class for the current model
      Severity: Minor
      Found in django/db/models/sql/query.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

      Function add_ordering has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_ordering(self, *ordering):
              """
              Add items from the 'ordering' sequence to the query's "order by"
              clause. These items are either field names (not column names) --
              possibly with a direction prefix ('-' or '?') -- or OrderBy
      Severity: Minor
      Found in django/db/models/sql/query.py - About 3 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

      Function resolve_ref has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def resolve_ref(self, name, allow_joins=True, reuse=None, summarize=False):
              if not allow_joins and LOOKUP_SEP in name:
                  raise FieldError("Joined field references are not permitted in this query")
              annotation = self.annotations.get(name)
              if annotation is not None:
      Severity: Minor
      Found in django/db/models/sql/query.py - About 3 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

      Function set_values has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_values(self, fields):
              self.select_related = False
              self.clear_deferred_loading()
              self.clear_select_fields()
      
      
      Severity: Minor
      Found in django/db/models/sql/query.py - About 3 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

      Function get_aggregation has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_aggregation(self, using, added_aggregate_names):
              """
              Return the dictionary with the values of the existing aggregations.
              """
              if not self.annotation_select:
      Severity: Minor
      Found in django/db/models/sql/query.py - About 3 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

      Function rewrite_cols has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def rewrite_cols(self, annotation, col_cnt):
              # We must make sure the inner query has the referred columns in it.
              # If we are aggregating over an annotation, then Django uses Ref()
              # instances to note this. However, if we are annotating over a column
              # of a related model, then it might be that column isn't part of the
      Severity: Minor
      Found in django/db/models/sql/query.py - About 2 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

      Function trim_start has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def trim_start(self, names_with_path):
              """
              Trim joins from the start of the join path. The candidates for trim
              are the PathInfos in names_with_path structure that are m2m joins.
      
      
      Severity: Minor
      Found in django/db/models/sql/query.py - About 2 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

      Function combine has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def combine(self, rhs, connector):
              """
              Merge the 'rhs' query into the current one (with any 'rhs' effects
              being applied *after* (that is, "to the right of") anything in the
              current query. 'rhs' is not modified during a call to this function.
      Severity: Minor
      Found in django/db/models/sql/query.py - About 2 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

      Function set_group_by has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_group_by(self, allow_aliases=True):
              """
              Expand the GROUP BY clause required by the query.
      
              This will usually be the set of all non-aggregate fields in the
      Severity: Minor
      Found in django/db/models/sql/query.py - About 2 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

      Function add_extra has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_extra(self, select, select_params, where, params, tables, order_by):
              """
              Add data to the various extra_* attributes for user-created additions
              to the query.
              """
      Severity: Minor
      Found in django/db/models/sql/query.py - About 2 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

      Function __init__ has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, model, where=WhereNode, alias_cols=True):
              self.model = model
              self.alias_refcount = {}
              # alias_map is the most important data structure regarding joins.
              # It's used for recording which joins exist in the query and what
      Severity: Minor
      Found in django/db/models/sql/query.py - About 1 hr to fix

        Function bump_prefix has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def bump_prefix(self, outer_query):
                """
                Change the alias prefix to the next letter in the alphabet in a way
                that the outer query's aliases and this query's aliases will not
                conflict. Even tables that previously had no alias will get an alias
        Severity: Minor
        Found in django/db/models/sql/query.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 add_filtered_relation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def add_filtered_relation(self, filtered_relation, alias):
                filtered_relation.alias = alias
                lookups = dict(get_children_from_q(filtered_relation.condition))
                relation_lookup_parts, relation_field_parts, _ = self.solve_lookup_type(filtered_relation.relation_name)
                if relation_lookup_parts:
        Severity: Minor
        Found in django/db/models/sql/query.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 join has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def join(self, join, reuse=None, reuse_with_filtered_relation=False):
                """
                Return an alias for the 'join', either reusing an existing alias for
                that join or creating a new one. 'join' is either a
                sql.datastructures.BaseTable or Join.
        Severity: Minor
        Found in django/db/models/sql/query.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 build_lookup has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def build_lookup(self, lookups, lhs, rhs):
                """
                Try to extract transforms and lookup from given lhs.
        
                The lhs value is something that works like SQLExpression.
        Severity: Minor
        Found in django/db/models/sql/query.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 change_aliases has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def change_aliases(self, change_map):
                """
                Change the aliases in change_map (which maps old-alias -> new-alias),
                relabelling any references to them in select columns and the where
                clause.
        Severity: Minor
        Found in django/db/models/sql/query.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 add_fields has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def add_fields(self, field_names, allow_m2m=True):
                """
                Add the given (model) fields to the select set. Add the field names in
                the order specified.
                """
        Severity: Minor
        Found in django/db/models/sql/query.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 combine has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def combine(self, rhs, connector):
                """
                Merge the 'rhs' query into the current one (with any 'rhs' effects
                being applied *after* (that is, "to the right of") anything in the
                current query. 'rhs' is not modified during a call to this function.
        Severity: Minor
        Found in django/db/models/sql/query.py - About 1 hr to fix

          Function build_filter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def build_filter(self, filter_expr, branch_negated=False, current_negated=False,
                               can_reuse=None, allow_joins=True, split_subq=True,
                               reuse_with_filtered_relation=False, check_filterable=True):
                  """
                  Build a WhereNode for a single filter clause but don't add it
          Severity: Minor
          Found in django/db/models/sql/query.py - About 1 hr to fix

            Function build_filter has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def build_filter(self, filter_expr, branch_negated=False, current_negated=False,
            Severity: Major
            Found in django/db/models/sql/query.py - About 1 hr to fix

              Function clone has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def clone(self):
                      """
                      Return a copy of the current Query. A lightweight alternative to
                      to deepcopy().
                      """
              Severity: Minor
              Found in django/db/models/sql/query.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 resolve_expression has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def resolve_expression(self, query, *args, **kwargs):
                      clone = self.clone()
                      # Subqueries need to use a different set of aliases than the outer query.
                      clone.bump_prefix(query)
                      clone.subquery = True
              Severity: Minor
              Found in django/db/models/sql/query.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 check_related_objects has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def check_related_objects(self, field, value, opts):
                      """Check the type of object passed to query relations."""
                      if field.is_relation:
                          # Check that the field and the queryset use the same model in a
                          # query like .filter(author=Author.objects.all()). For example, the
              Severity: Minor
              Found in django/db/models/sql/query.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 set_limits has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def set_limits(self, low=None, high=None):
                      """
                      Adjust the limits on the rows retrieved. Use low/high to set these,
                      as it makes it more Pythonic to read and write. When the SQL query is
                      created, convert them to the appropriate offset and limit values.
              Severity: Minor
              Found in django/db/models/sql/query.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 _add_q has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def _add_q(self, q_object, used_aliases, branch_negated=False,
              Severity: Major
              Found in django/db/models/sql/query.py - About 50 mins to fix

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

                    def setup_joins(self, names, opts, alias, can_reuse=None, allow_many=True,
                Severity: Minor
                Found in django/db/models/sql/query.py - About 45 mins to fix

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

                      def add_extra(self, select, select_params, where, params, tables, order_by):
                  Severity: Minor
                  Found in django/db/models/sql/query.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if p.m2m:
                                                cur_names_with_path[1].extend(pathinfos[0:inner_pos + 1])
                                                names_with_path.append(cur_names_with_path)
                                                raise MultiJoin(pos + 1, names_with_path)
                                    last = pathinfos[-1]
                    Severity: Major
                    Found in django/db/models/sql/query.py - About 45 mins to fix

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

                          def trim_joins(self, targets, joins, path):
                              """
                              The 'target' parameter is the final field being joined to, 'joins'
                              is the full list of join aliases. The 'path' contain the PathInfos
                              used to create the joins.
                      Severity: Minor
                      Found in django/db/models/sql/query.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 join_parent_model has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def join_parent_model(self, opts, model, alias, seen):
                              """
                              Make sure the given 'model' is joined in the query. If 'model' isn't
                              a parent of 'opts' or if it is None this method is a no-op.
                      
                      
                      Severity: Minor
                      Found in django/db/models/sql/query.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 promote_joins has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def promote_joins(self, aliases):
                              """
                              Promote recursively the join type of given aliases and its children to
                              an outer join. If 'unconditional' is False, only promote the join if
                              it is nullable or the parent join is an outer join.
                      Severity: Minor
                      Found in django/db/models/sql/query.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 update_join_types has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def update_join_types(self, query):
                              """
                              Change join types so that the generated query is as efficient as
                              possible, but still correct. So, change as many joins as possible
                              to INNER, but don't make OUTER joins INNER if that could remove
                      Severity: Minor
                      Found in django/db/models/sql/query.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

                      Avoid too many return statements within this function.
                      Open

                              return clause, used_joins if not require_outer else ()
                      Severity: Major
                      Found in django/db/models/sql/query.py - About 30 mins to fix

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

                            def demote_joins(self, aliases):
                                """
                                Change join type from LOUTER to INNER for all joins in aliases.
                        
                                Similarly to promote_joins(), this method must ensure no join chains
                        Severity: Minor
                        Found in django/db/models/sql/query.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