django/django

View on GitHub

Showing 1,786 of 2,094 total issues

Function __init__ has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, ds_input, write=False):
        self._write = 1 if write else 0
        Driver.ensure_registered()

        # Preprocess json inputs. This converts json strings to dictionaries,
Severity: Minor
Found in django/contrib/gis/gdal/raster/source.py - About 6 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

File storage.py has 419 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import os
import posixpath
import re
from hashlib import md5
Severity: Minor
Found in django/contrib/staticfiles/storage.py - About 6 hrs to fix

    File base.py has 416 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import logging
    import string
    from datetime import datetime, timedelta
    
    from asgiref.sync import sync_to_async
    Severity: Minor
    Found in django/contrib/sessions/backends/base.py - About 6 hrs to fix

      Function format has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

      def format(
          number,
          decimal_sep,
          decimal_pos=None,
          grouping=0,
      Severity: Minor
      Found in django/utils/numberformat.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 handle has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle(self, **options):
              db = options["database"]
              include_stale_apps = options["include_stale_apps"]
              interactive = options["interactive"]
              verbosity = options["verbosity"]

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

          def show_list(self, connection, app_names=None):
              """
              Show a list of all migrations on the system, or only those of
              some named apps.
              """
      Severity: Minor
      Found in django/core/management/commands/showmigrations.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 check_all_models has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

      def check_all_models(app_configs=None, **kwargs):
          db_table_models = defaultdict(list)
          indexes = defaultdict(list)
          constraints = defaultdict(list)
          errors = []
      Severity: Minor
      Found in django/core/checks/model_checks.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

      File creation.py has 413 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import sys
      
      from django.conf import settings
      from django.db import DatabaseError
      from django.db.backends.base.creation import BaseDatabaseCreation
      Severity: Minor
      Found in django/db/backends/oracle/creation.py - About 5 hrs to fix

        File deletion.py has 411 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from collections import Counter, defaultdict
        from functools import partial, reduce
        from itertools import chain
        from operator import attrgetter, or_
        
        
        Severity: Minor
        Found in django/db/models/deletion.py - About 5 hrs to fix

          File message.py has 408 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import mimetypes
          from email import charset as Charset
          from email import encoders as Encoders
          from email import generator, message_from_string
          from email.errors import HeaderParseError
          Severity: Minor
          Found in django/core/mail/message.py - About 5 hrs to fix

            Function _remake_table has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
            Open

                def _remake_table(
                    self, model, create_field=None, delete_field=None, alter_fields=None
                ):
                    """
                    Shortcut to transform a model from old_model into new_model
            Severity: Minor
            Found in django/db/backends/sqlite3/schema.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 write_migration_files has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
            Open

                def write_migration_files(self, changes, update_previous_migration_paths=None):
                    """
                    Take a changes dict and write them out as migration files.
                    """
                    directory_created = {}
            Severity: Minor
            Found in django/core/management/commands/makemigrations.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

            File _functions.py has 404 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """
            Implementations of SQL functions for SQLite.
            """
            
            import functools
            Severity: Minor
            Found in django/db/backends/sqlite3/_functions.py - About 5 hrs to fix

              Function get_group_by has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_group_by(self, select, order_by):
                      """
                      Return a list of 2-tuples of form (sql, params).
              
                      The logic of what exactly the GROUP BY clause contains is hard
              Severity: Minor
              Found in django/db/models/sql/compiler.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 build_filter has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                  def build_filter(
                      self,
                      filter_expr,
                      branch_negated=False,
                      current_negated=False,
              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

              File models.py has 398 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              from collections.abc import Iterable
              
              from django.apps import apps
              from django.contrib import auth
              from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
              Severity: Minor
              Found in django/contrib/auth/models.py - About 5 hrs to fix

                File xml_serializer.py has 398 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                """
                XML serializer.
                """
                
                import json
                Severity: Minor
                Found in django/core/serializers/xml_serializer.py - About 5 hrs to fix

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

                  def parse_bits(
                      parser,
                      bits,
                      params,
                      varargs,
                  Severity: Minor
                  Found in django/template/library.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 _alter_field has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _alter_field(
                          self,
                          model,
                          old_field,
                          new_field,
                  Severity: Minor
                  Found in django/db/backends/sqlite3/schema.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

                  File text.py has 392 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import gzip
                  import re
                  import secrets
                  import unicodedata
                  from collections import deque
                  Severity: Minor
                  Found in django/utils/text.py - About 5 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language