django/django

View on GitHub

Showing 1,784 of 2,092 total issues

Avoid deeply nested control flow statements.
Open

                        if (
                            self.query.has_select_fields
                            and col_alias in self.query.annotation_select
                            and not (
                                isinstance(expr_src, F) and col_alias == expr_src.name
Severity: Major
Found in django/db/models/sql/compiler.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/fields/__init__.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if objs:
                                  key = "'%s.%s'" % (related_model.__name__, field.name)
                                  restricted_objects[key] += objs
                      if restricted_objects:
      Severity: Major
      Found in django/db/models/deletion.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if isinstance(new_obj, list):
                                new_obj_list.extend(new_obj)
                            else:
                                new_obj_list.append(new_obj)
                        obj_list = new_obj_list
        Severity: Major
        Found in django/db/models/query.py - About 45 mins to fix

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

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

            Function get_accessor_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_accessor_name(self, model=None):
                    # This method encapsulates the logic that decides what name to give an
                    # accessor descriptor that retrieves related many-to-one or
                    # many-to-many objects. It uses the lowercased object_name + "_set",
                    # but this can be overridden with the "related_name" option. Due to
            Severity: Minor
            Found in django/db/models/fields/reverse_related.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 _check_db_comment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def _check_db_comment(self, databases=None, **kwargs):
                    if not self.db_comment or not databases:
                        return []
                    errors = []
                    for db in databases:
            Severity: Minor
            Found in django/db/models/fields/__init__.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

            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 get_paths_from_expression has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_paths_from_expression(expr):
                  if isinstance(expr, F):
                      yield expr.name
                  elif hasattr(expr, "flatten"):
                      for child in expr.flatten():
              Severity: Minor
              Found in django/db/models/sql/query.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_column_collations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _get_column_collations(self, cursor, table_name):
                      row = cursor.execute(
                          """
                          SELECT sql
                          FROM sqlite_master
              Severity: Minor
              Found in django/db/backends/sqlite3/introspection.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 trim_joins has a Cognitive Complexity of 8 (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 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 promote_joins has a Cognitive Complexity of 8 (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 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 update_join_types has a Cognitive Complexity of 8 (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 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 _sqlite_datetime_trunc has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def _sqlite_datetime_trunc(lookup_type, dt, tzname, conn_tzname):
                  dt = _sqlite_datetime_parse(dt, tzname, conn_tzname)
                  if dt is None:
                      return None
                  if lookup_type == "year":
              Severity: Minor
              Found in django/db/backends/sqlite3/_functions.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 _sqlite_time_trunc has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def _sqlite_time_trunc(lookup_type, dt, tzname, conn_tzname):
                  if dt is None:
                      return None
                  dt_parsed = _sqlite_datetime_parse(dt, tzname, conn_tzname)
                  if dt_parsed is None:
              Severity: Minor
              Found in django/db/backends/sqlite3/_functions.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 quote_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def quote_value(self, value):
                      # The backend "mostly works" without this function and there are use
                      # cases for compiling Python without the sqlite3 libraries (e.g.
                      # security hardening).
                      try:
              Severity: Minor
              Found in django/db/backends/sqlite3/schema.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 resolve_expression has a Cognitive Complexity of 8 (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 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 sql_flush has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def sql_flush(self, style, tables, *, reset_sequences=False, allow_cascade=False):
              Severity: Minor
              Found in django/db/backends/sqlite3/operations.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 unique_columns:
                                              # Stop constraint parsing.
                                              unique = False
                                          continue
                  Severity: Major
                  Found in django/db/backends/sqlite3/introspection.py - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language