django/django

View on GitHub

Showing 1,784 of 2,092 total issues

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

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

        def to_python(self, value):
            if value is None:
                return value
            if isinstance(value, datetime.datetime):
                if settings.USE_TZ and timezone.is_aware(value):
    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 obj in old_objs:
                                    old_objs.remove(obj)
                                else:
                                    new_objs.append(obj)
    
    
    Severity: Major
    Found in django/db/models/fields/related_descriptors.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if through_attr in getattr(obj, "_prefetched_objects_cache", ()):
                              # If related objects have been prefetched, use the
                              # cache rather than the object's through_attr.
                              new_obj = list(obj._prefetched_objects_cache.get(through_attr))
                          else:
      Severity: Major
      Found in django/db/models/query.py - About 45 mins to fix

        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, template=None):
                  # Process JSON path from the left-hand side.
                  if isinstance(self.lhs, KeyTransform):
                      lhs, lhs_params, lhs_key_transforms = self.lhs.preprocess_lhs(
                          compiler, connection
          Severity: Minor
          Found in django/db/models/fields/json.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 __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

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

              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 q.has_select_fields:
                                          raise DatabaseError(
                                              "ORDER BY term does not match any column in "
                                              "the result set."
                                          )
              Severity: Major
              Found in django/db/models/sql/compiler.py - About 45 mins to fix

                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

                  Avoid deeply nested control flow statements.
                  Open

                                      if new_obj is None:
                                          continue
                                      # We special-case `list` rather than something more generic
                                      # like `Iterable` because we don't want to accidentally match
                                      # user models that define __iter__.
                  Severity: Major
                  Found in django/db/models/query.py - About 45 mins to fix

                    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

                      Avoid deeply nested control flow statements.
                      Open

                                              for expr in expression.flatten():
                                                  if isinstance(expr, F) and expr.name in exclude:
                                                      return
                                          elif isinstance(expression, F) and expression.name in exclude:
                      Severity: Major
                      Found in django/db/models/constraints.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if hasattr(base_fn, "alters_data"):
                                                    fn.alters_data = base_fn.alters_data
                                                break
                        Severity: Major
                        Found in django/db/models/utils.py - About 45 mins to fix

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

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

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

                                def find_ordering_name(
                            Severity: Minor
                            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 value == optgroup_key:
                                                            return
                                                elif value == option_key:
                                Severity: Major
                                Found in django/db/models/fields/__init__.py - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language