django/django

View on GitHub

Showing 2,090 of 2,090 total issues

File json.py has 501 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json

from django import forms
from django.core import checks, exceptions
from django.db import NotSupportedError, connections, router
Severity: Major
Found in django/db/models/fields/json.py - About 1 day to fix

    File i18n.py has 498 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from decimal import Decimal
    
    from django.conf import settings
    from django.template import Library, Node, TemplateSyntaxError, Variable
    from django.template.base import TokenType, render_value_in_context
    Severity: Minor
    Found in django/templatetags/i18n.py - About 7 hrs to fix

      Function sort_dependencies has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
      Open

      def sort_dependencies(app_list, allow_cycles=False):
          """Sort a list of (app_config, models) pairs into a single list of models.
      
          The single list of models is sorted so that any model with a natural key
          is serialized before a normal model, and any model with a natural key
      Severity: Minor
      Found in django/core/serializers/__init__.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 trans_real.py has 493 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Translation helper functions."""
      
      import functools
      import gettext as gettext_module
      import os
      Severity: Minor
      Found in django/utils/translation/trans_real.py - About 7 hrs to fix

        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 489 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
                      Severity
                      Category
                      Status
                      Source
                      Language