django/django

View on GitHub

Showing 1,637 of 2,124 total issues

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

"""
This is the Django template system.

How it works:

Severity: Major
Found in django/template/base.py - About 2 days to fix

    Function create_forward_many_to_many_manager has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_forward_many_to_many_manager(superclass, rel, reverse):
        """
        Create a manager for the either side of a many-to-many relation.
    
        This manager subclasses another manager, generally the default manager of
    Severity: Minor
    Found in django/db/models/fields/related_descriptors.py - About 1 day 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 86 (exceeds 5 allowed). Consider refactoring.
    Open

        def _alter_field(self, model, old_field, new_field, old_type, new_type,
                         old_db_params, new_db_params, strict=False):
            """Perform a "physical" (non-ManyToMany) field update."""
            # Drop any FK constraints, we'll remake them later
            fks_dropped = set()
    Severity: Minor
    Found in django/db/backends/base/schema.py - About 1 day 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 parse has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse(self):
            """
            Parse the POST data and break it into a FILES MultiValueDict and a POST
            MultiValueDict.
    
    
    Severity: Minor
    Found in django/http/multipartparser.py - About 1 day 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 721 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from django.db import models
    from django.db.migrations.operations.base import Operation
    from django.db.migrations.state import ModelState
    from django.db.models.options import normalize_together
    from django.utils.functional import cached_property
    Severity: Major
    Found in django/db/migrations/operations/models.py - About 1 day to fix

      Function _build_migration_list has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
      Open

          def _build_migration_list(self, graph=None):
              """
              Chop the lists of operations up into migrations with dependencies on
              each other. Do this by going through an app's list of operations until
              one is found that has an outgoing dependency that isn't in another
      Severity: Minor
      Found in django/db/migrations/autodetector.py - About 1 day 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 defaultfilters.py has 706 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Default variable filters."""
      import random as random_module
      import re
      import types
      from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation
      Severity: Major
      Found in django/template/defaultfilters.py - About 1 day to fix

        Query has 85 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Query(BaseExpression):
            """A single SQL query."""
        
            alias_prefix = 'T'
            subq_aliases = frozenset([alias_prefix])
        Severity: Major
        Found in django/db/models/sql/query.py - About 1 day to fix

          Function handle has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle(self, *app_labels, **options):
                  format = options['format']
                  indent = options['indent']
                  using = options['database']
                  excludes = options['exclude']
          Severity: Minor
          Found in django/core/management/commands/dumpdata.py - About 1 day 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 create_reverse_many_to_one_manager has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
          Open

          def create_reverse_many_to_one_manager(superclass, rel):
              """
              Create a manager for the reverse side of a many-to-one relation.
          
              This manager subclasses another manager, generally the default manager of
          Severity: Minor
          Found in django/db/models/fields/related_descriptors.py - About 1 day 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 _parse_column_or_constraint_definition has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
          Open

              def _parse_column_or_constraint_definition(self, tokens, columns):
                  token = None
                  is_constraint_definition = None
                  field_name = None
                  constraint_name = None
          Severity: Minor
          Found in django/db/backends/sqlite3/introspection.py - About 1 day 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

          GEOSGeometryBase has 81 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class GEOSGeometryBase(GEOSBase):
          
              _GEOS_CLASSES = None
          
              ptr_type = GEOM_PTR
          Severity: Major
          Found in django/contrib/gis/geos/geometry.py - About 1 day to fix

            QuerySet has 80 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class QuerySet:
                """Represent a lazy database lookup for a set of objects."""
            
                def __init__(self, model=None, query=None, using=None, hints=None):
                    self.model = model
            Severity: Major
            Found in django/db/models/query.py - About 1 day to fix

              Function save has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
              Open

                  def save(self, verbose=False, fid_range=False, step=False,
                           progress=False, silent=False, stream=sys.stdout, strict=False):
                      """
                      Save the contents from the OGR DataSource Layer into the database
                      according to the mapping dictionary given at initialization.
              Severity: Minor
              Found in django/contrib/gis/utils/layermapping.py - About 1 day 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 prefetch_related_objects has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
              Open

              def prefetch_related_objects(model_instances, *related_lookups):
                  """
                  Populate prefetched object caches for a list of model instances based on
                  the lookups/Prefetch instances given.
                  """
              Severity: Minor
              Found in django/db/models/query.py - About 1 day 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_inspection has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
              Open

                  def handle_inspection(self, options):
                      connection = connections[options['database']]
                      # 'table_name_filter' is a stealth option
                      table_name_filter = options.get('table_name_filter')
              
              
              Severity: Minor
              Found in django/core/management/commands/inspectdb.py - About 1 day 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 options.py has 632 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import copy
              import inspect
              from bisect import bisect
              from collections import defaultdict
              
              
              Severity: Major
              Found in django/db/models/options.py - About 1 day to fix

                Function handle has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
                Open

                    def handle(self, *args, **options):
                        username = options[self.UserModel.USERNAME_FIELD]
                        database = options['database']
                        user_data = {}
                        verbose_field_name = self.username_field.verbose_name
                Severity: Minor
                Found in django/contrib/auth/management/commands/createsuperuser.py - About 1 day 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

                BaseDatabaseOperations has 73 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class BaseDatabaseOperations:
                    """
                    Encapsulate backend-specific differences, such as the way a backend
                    performs ordering or calculates the ID of a recently-inserted row.
                    """
                Severity: Major
                Found in django/db/backends/base/operations.py - About 1 day to fix

                  Function handle has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def handle(self, *args, **options):
                  
                          self.verbosity = options['verbosity']
                          self.interactive = options['interactive']
                  
                  
                  Severity: Minor
                  Found in django/core/management/commands/migrate.py - About 1 day 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