django/django

View on GitHub

Showing 1,784 of 2,092 total issues

Function __exit__ has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

    def __exit__(self, exc_type, exc_value, traceback):
        connection = get_connection(self.using)

        if connection.in_atomic_block:
            connection.atomic_blocks.pop()
Severity: Minor
Found in django/db/transaction.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 validate_unique has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_unique(self):
        # Collect unique_checks and date_checks to run from all the forms.
        all_unique_checks = set()
        all_date_checks = set()
        forms_to_delete = self.deleted_forms
Severity: Minor
Found in django/forms/models.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

File widgets.py has 488 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Form Widget classes specific to the Django admin site.
"""

import copy
Severity: Minor
Found in django/contrib/admin/widgets.py - About 7 hrs to fix

    Function create_generic_related_manager has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_generic_related_manager(superclass, rel):
        """
        Factory function to create a manager that subclasses another manager
        (generally the default manager of a given model) and adds behaviors
        specific to generic relations.
    Severity: Minor
    Found in django/contrib/contenttypes/fields.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

    File helpers.py has 477 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import json
    
    from django import forms
    from django.contrib.admin.utils import (
        display_for_field,
    Severity: Minor
    Found in django/contrib/admin/helpers.py - About 7 hrs to fix

      File sites.py has 476 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from functools import update_wrapper
      from weakref import WeakSet
      
      from django.apps import apps
      from django.conf import settings
      Severity: Minor
      Found in django/contrib/admin/sites.py - About 7 hrs to fix

        Function migration_plan has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
        Open

            def migration_plan(self, targets, clean_start=False):
                """
                Given a set of targets, return a list of (Migration instance, backwards?).
                """
                plan = []
        Severity: Minor
        Found in django/db/migrations/executor.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 __init__ has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(
                self,
                path,
                *,
                match=None,
        Severity: Minor
        Found in django/forms/fields.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

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

        """
        PostgreSQL database backend for Django.
        
        Requires psycopg2 >= 2.8.4 or psycopg >= 3.1.8
        """
        Severity: Minor
        Found in django/db/backends/postgresql/base.py - About 7 hrs to fix

          File formsets.py has 470 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from django.core.exceptions import ValidationError
          from django.forms import Form
          from django.forms.fields import BooleanField, IntegerField
          from django.forms.renderers import get_default_renderer
          from django.forms.utils import ErrorList, RenderableFormMixin
          Severity: Minor
          Found in django/forms/formsets.py - About 7 hrs to fix

            File forms.py has 470 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import unicodedata
            
            from django import forms
            from django.contrib.auth import authenticate, get_user_model, password_validation
            from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, identify_hasher
            Severity: Minor
            Found in django/contrib/auth/forms.py - About 7 hrs to fix

              Function Deserializer has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
              Open

              def Deserializer(
                  object_list, *, using=DEFAULT_DB_ALIAS, ignorenonexistent=False, **options
              ):
                  """
                  Deserialize simple Python objects back into Django ORM instances.
              Severity: Minor
              Found in django/core/serializers/python.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 _resolve_lookup has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _resolve_lookup(self, context):
                      """
                      Perform resolution of a real variable (i.e. not a literal) against the
                      given context.
              
              
              Severity: Minor
              Found in django/template/base.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 check_layer has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
              Open

                  def check_layer(self):
                      """
                      Check the Layer metadata and ensure that it's compatible with the
                      mapping information and model. Unlike previous revisions, there is no
                      need to increment through each feature in the Layer.
              Severity: Minor
              Found in django/contrib/gis/utils/layermapping.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 _post_process has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _post_process(self, paths, adjustable_paths, hashed_files):
                      # Sort the files by directory level
                      def path_level(name):
                          return len(name.split(os.sep))
              
              
              Severity: Minor
              Found in django/contrib/staticfiles/storage.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

              File admin_list.py has 456 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import datetime
              
              from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
              from django.contrib.admin.utils import (
                  display_for_field,
              Severity: Minor
              Found in django/contrib/admin/templatetags/admin_list.py - About 6 hrs to fix

                Function _changeform_view has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _changeform_view(self, request, object_id, form_url, extra_context):
                        to_field = request.POST.get(TO_FIELD_VAR, request.GET.get(TO_FIELD_VAR))
                        if to_field and not self.to_field_allowed(request, to_field):
                            raise DisallowedModelAdminToField(
                                "The field %s cannot be referenced." % to_field
                Severity: Minor
                Found in django/contrib/admin/options.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 migrate.py has 452 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import sys
                import time
                from importlib import import_module
                
                from django.apps import apps
                Severity: Minor
                Found in django/core/management/commands/migrate.py - About 6 hrs to fix

                  File functions.py has 451 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  from decimal import Decimal
                  
                  from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
                  from django.contrib.gis.db.models.sql import AreaField, DistanceField
                  from django.contrib.gis.geos import GEOSGeometry
                  Severity: Minor
                  Found in django/contrib/gis/db/models/functions.py - About 6 hrs to fix

                    Function generate_altered_fields has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def generate_altered_fields(self):
                            """
                            Make AlterField operations, or possibly RemovedField/AddField if alter
                            isn't possible.
                            """
                    Severity: Minor
                    Found in django/db/migrations/autodetector.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

                    Severity
                    Category
                    Status
                    Source
                    Language