django/django

View on GitHub

Showing 1,784 of 2,092 total issues

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

    def save(
        self,
        verbose=False,
        fid_range=False,
        step=False,
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

BaseDatabaseOperations has 77 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

    BaseDatabaseSchemaEditor has 77 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BaseDatabaseSchemaEditor:
        """
        This class and its subclasses are responsible for emitting schema-changing
        statements to the databases - model creation/removal/alteration, field
        renaming, index fiddling, and so on.
    Severity: Major
    Found in django/db/backends/base/schema.py - About 1 day to fix

      File geometries.py has 630 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
       The OGRGeometry is a wrapper for using the OGR Geometry class
       (see https://gdal.org/api/ogrgeometry_cpp.html#_CPPv411OGRGeometry).
       OGRGeometry may be instantiated when reading geometries from OGR Data Sources
       (e.g. SHP files), or when given OGC WKT (a string).
      Severity: Major
      Found in django/contrib/gis/gdal/geometries.py - About 1 day to fix

        File __init__.py has 627 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        LANG_INFO is a dictionary structure to provide meta information about languages.
        
        About name_local: capitalize it as if your language name was appearing
        inside a sentence in your language.
        Severity: Major
        Found in django/conf/locale/__init__.py - About 1 day to fix

          File geometry.py has 624 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """
           This module contains the 'base' GEOSGeometry object -- all GEOS Geometries
           inherit from this object.
          """
          
          
          Severity: Major
          Found in django/contrib/gis/geos/geometry.py - About 1 day to fix

            File filters.py has 620 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """
            This encapsulates the logic for displaying filters in the Django admin.
            Filters are specified in models with the "list_filter" option.
            
            Each filter subclass knows how to display a filter for a field that passes a
            Severity: Major
            Found in django/contrib/admin/filters.py - About 1 day to fix

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

              import _thread
              import copy
              import datetime
              import logging
              import threading
              Severity: Major
              Found in django/db/backends/base/base.py - About 1 day to fix

                File dates.py has 612 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import datetime
                
                from django.conf import settings
                from django.core.exceptions import ImproperlyConfigured
                from django.db import models
                Severity: Major
                Found in django/views/generic/dates.py - About 1 day to fix

                  File constraints.py has 612 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import warnings
                  from enum import Enum
                  from types import NoneType
                  
                  from django.core import checks
                  Severity: Major
                  Found in django/db/models/constraints.py - About 1 day to fix

                    Function reduce has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def reduce(self, operation, app_label):
                            if (
                                isinstance(operation, DeleteModel)
                                and self.name_lower == operation.name_lower
                                and not self.options.get("proxy", False)
                    Severity: Minor
                    Found in django/db/migrations/operations/models.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 operations.py has 607 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import datetime
                    import uuid
                    from functools import lru_cache
                    
                    from django.conf import settings
                    Severity: Major
                    Found in django/db/backends/oracle/operations.py - About 1 day to fix

                      Function normalize has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def normalize(pattern):
                          r"""
                          Given a reg-exp pattern, normalize it to an iterable of forms that
                          suffice for reverse matching. This does the following:
                      
                      
                      Severity: Minor
                      Found in django/utils/regex_helper.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 lookups.py has 599 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import itertools
                      import math
                      import warnings
                      
                      from django.core.exceptions import EmptyResultSet, FullResultSet
                      Severity: Major
                      Found in django/db/models/lookups.py - About 1 day to fix

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

                            def handle(self, **options):
                                self.verbosity = options["verbosity"]
                                self.interactive = options["interactive"]
                                app_label = options["app_label"]
                                start_migration_name = options["start_migration_name"]
                        Severity: Minor
                        Found in django/core/management/commands/squashmigrations.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 has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def handle(self, app_or_project, name, target=None, **options):
                                self.app_or_project = app_or_project
                                self.a_or_an = "an" if app_or_project == "app" else "a"
                                self.paths_to_remove = []
                                self.verbosity = options["verbosity"]
                        Severity: Minor
                        Found in django/core/management/templates.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 base.py has 589 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        """
                        Base classes for writing management commands (named commands which can
                        be executed through ``django-admin`` or ``manage.py``).
                        """
                        
                        
                        Severity: Major
                        Found in django/core/management/base.py - About 1 day to fix

                          Function _reverse_with_prefix has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def _reverse_with_prefix(self, lookup_view, _prefix, *args, **kwargs):
                                  if args and kwargs:
                                      raise ValueError("Don't mix *args and **kwargs in call to reverse()!")
                          
                                  if not self._populated:
                          Severity: Minor
                          Found in django/urls/resolvers.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 request.py has 579 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import codecs
                          import copy
                          from io import BytesIO
                          from itertools import chain
                          from urllib.parse import parse_qsl, quote, urlencode, urljoin, urlsplit
                          Severity: Major
                          Found in django/http/request.py - About 1 day to fix

                            Function _create_test_db has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def _create_test_db(self, verbosity=1, autoclobber=False, keepdb=False):
                                    parameters = self._get_test_db_params()
                                    with self._maindb_connection.cursor() as cursor:
                                        if self._test_database_create():
                                            try:
                            Severity: Minor
                            Found in django/db/backends/oracle/creation.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