django/django

View on GitHub

Showing 1,782 of 2,090 total issues

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

    def add_update_values(self, values):
        """
        Convert a dictionary of field name to value mappings into an update
        query. This is the entry point for the public update() method on
        querysets.
Severity: Minor
Found in django/db/models/sql/subqueries.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 bulk_create has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

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

        def add_deferred_loading(self, field_names):
            """
            Add the given list of model field names to the set of fields to
            exclude from loading from the database when automatic column selection
            is done. Add the new field names to any existing field names that
    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

    Avoid deeply nested control flow statements.
    Open

                            if value == optgroup_key:
                                return
                    elif value == option_key:
    Severity: Major
    Found in django/db/models/fields/__init__.py - About 45 mins to fix

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

          def _extract_model_params(self, defaults, **kwargs):
              """
              Prepare `params` for creating a model instance based on the given
              kwargs; for use by get_or_create().
              """
      Severity: Minor
      Found in django/db/models/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

      Avoid deeply nested control flow statements.
      Open

                              if field != opts.pk:
                                  setattr(obj_with_pk, field.attname, result)
                      for obj_with_pk in objs_with_pk:
      Severity: Major
      Found in django/db/models/query.py - About 45 mins to fix

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

            def as_sql(self, compiler, connection):
                sql, params = compiler.compile(self.lhs)
                lhs_output_field = self.lhs.output_field
                if isinstance(lhs_output_field, DateTimeField):
                    tzname = self.get_tzname()
        Severity: Minor
        Found in django/db/models/functions/datetime.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 constraint is self:
                                    raise ValidationError(
                                        instance.unique_error_message(model, self.fields),
                                    )
                else:
        Severity: Major
        Found in django/db/models/constraints.py - About 45 mins to fix

          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

          Avoid deeply nested control flow statements.
          Open

                                  if field.name != field.attname:
                                      update_fields.add(field.attname)
                          obj.save(using=self.db, update_fields=update_fields)
          Severity: Major
          Found in django/db/models/query.py - About 45 mins to fix

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

                def _alter_column_type_sql(
            Severity: Minor
            Found in django/db/backends/postgresql/schema.py - About 45 mins to fix

              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

              Avoid deeply nested control flow statements.
              Open

                                      if annotation.get_group_by_cols():
                                          annotation_mask.add(annotation_alias)
                                  inner_query.set_annotation_mask(annotation_mask)
              Severity: Major
              Found in django/db/models/sql/query.py - About 45 mins to fix

                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/mysql/operations.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

                    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 _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

                    Avoid deeply nested control flow statements.
                    Open

                                            for expr in self.group_by:
                                                annotation_mask |= expr.get_refs()
                                        for aggregate in aggregates.values():
                    Severity: Major
                    Found in django/db/models/sql/query.py - About 45 mins to fix

                      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

                      Avoid deeply nested control flow statements.
                      Open

                                              if self.annotation_select:
                                                  self.names_to_path(f.split(LOOKUP_SEP), self.model._meta)
                                              field_names.append(f)
                      Severity: Major
                      Found in django/db/models/sql/query.py - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language