django/django

View on GitHub

Showing 1,786 of 2,094 total issues

Function _live_receivers has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def _live_receivers(self, sender):
        """
        Filter sequence of receivers to get resolved, live receivers.

        This checks for weak references and resolves them, then returning only
Severity: Minor
Found in django/dispatch/dispatcher.py - About 4 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 arrange_for_graph has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def arrange_for_graph(self, changes, graph, migration_name=None):
        """
        Take a result from changes() and a MigrationGraph, and fix the names
        and dependencies of the changes so they extend the graph from the leaf
        nodes for each app.
Severity: Minor
Found in django/db/migrations/autodetector.py - About 4 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 split_having_qualify has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def split_having_qualify(self, negated=False, must_group_by=False):
        """
        Return three possibly None nodes: one for those parts of self that
        should be included in the WHERE clause, one for those parts of self
        that must be included in the HAVING clause, and one for those parts
Severity: Minor
Found in django/db/models/sql/where.py - About 4 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 get_constraints has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def get_constraints(self, cursor, table_name):
        """
        Retrieve any constraints or keys (unique, pk, fk, check, index) across
        one or more columns.
        """
Severity: Minor
Found in django/db/backends/mysql/introspection.py - About 4 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 find_files has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def find_files(self, root):
        """
        Get all files in the given root. Also check that there is a matching
        locale dir for each file.
        """
Severity: Minor
Found in django/core/management/commands/makemessages.py - About 4 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 loaddata.py has 363 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import functools
import glob
import gzip
import os
import sys
Severity: Minor
Found in django/core/management/commands/loaddata.py - About 4 hrs to fix

    File inspectdb.py has 363 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import keyword
    import re
    
    from django.core.management.base import BaseCommand, CommandError
    from django.db import DEFAULT_DB_ALIAS, connections
    Severity: Minor
    Found in django/core/management/commands/inspectdb.py - About 4 hrs to fix

      Function load_disk has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def load_disk(self):
              """Load the migrations from all INSTALLED_APPS from disk."""
              self.disk_migrations = {}
              self.unmigrated_apps = set()
              self.migrated_apps = set()
      Severity: Minor
      Found in django/db/migrations/loader.py - About 4 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 generate_deleted_models has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def generate_deleted_models(self):
              """
              Find all deleted models (managed and unmanaged) and make delete
              operations for them as well as separate operations to delete any
              foreign key or M2M relationships (these are optimized later, if
      Severity: Minor
      Found in django/db/migrations/autodetector.py - About 4 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 bulk_create has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def bulk_create(
              self,
              objs,
              batch_size=None,
              ignore_conflicts=False,
      Severity: Minor
      Found in django/db/models/query.py - About 4 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 as_sql has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def as_sql(self, compiler, connection):
              """
              Return the SQL version of the where clause and the value to be
              substituted in. Return '', [] if this node matches everything,
              None, [] if this node is empty, and raise EmptyResultSet if this
      Severity: Minor
      Found in django/db/models/sql/where.py - About 4 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 clean has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def clean(self, value):
              """
              Validate every value in the given list. A value is validated against
              the corresponding Field in self.fields.
      
      
      Severity: Minor
      Found in django/forms/fields.py - About 4 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 expand_to_include has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def expand_to_include(self, *args):
              """
              Modify the envelope to expand to include the boundaries of
              the passed-in 2-tuple (a point), 4-tuple (an extent) or
              envelope.
      Severity: Minor
      Found in django/contrib/gis/gdal/envelope.py - About 4 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 get_context_data has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_context_data(self, **kwargs):
              model_name = self.kwargs["model_name"]
              # Get the model class.
              try:
                  app_config = apps.get_app_config(self.kwargs["app_label"])
      Severity: Minor
      Found in django/contrib/admindocs/views.py - About 4 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 357 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      MySQL database backend for Django.
      
      Requires mysqlclient: https://pypi.org/project/mysqlclient/
      """
      Severity: Minor
      Found in django/db/backends/mysql/base.py - About 4 hrs to fix

        File html.py has 355 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """HTML utilities suitable for global use."""
        
        import html
        import json
        import re
        Severity: Minor
        Found in django/utils/html.py - About 4 hrs to fix

          ProjectState has 35 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class ProjectState:
              """
              Represent the entire project's overall state. This is the item that is
              passed around - do it here rather than at the app level so that cross-app
              FKs/etc. resolve properly.
          Severity: Minor
          Found in django/db/migrations/state.py - About 4 hrs to fix

            BaseFormSet has 35 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class BaseFormSet(RenderableFormMixin):
                """
                A collection of instances of the same Form class.
                """
            
            
            Severity: Minor
            Found in django/forms/formsets.py - About 4 hrs to fix

              SpatialReference has 35 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class SpatialReference(GDALBase):
                  """
                  A wrapper for the OGRSpatialReference object. According to the GDAL web site,
                  the SpatialReference object "provide[s] services to represent coordinate
                  systems (projections and datums) and to transform between them."
              Severity: Minor
              Found in django/contrib/gis/gdal/srs.py - About 4 hrs to fix

                File files.py has 352 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import datetime
                import posixpath
                
                from django import forms
                from django.core import checks
                Severity: Minor
                Found in django/db/models/fields/files.py - About 4 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language