django/django

View on GitHub

Showing 1,786 of 2,094 total issues

Function _constraint_names has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def _constraint_names(
        self,
        model,
        column_names=None,
        unique=None,
Severity: Minor
Found in django/db/backends/base/schema.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 operations.py has 349 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime
import decimal
import uuid
from functools import lru_cache
from itertools import chain
Severity: Minor
Found in django/db/backends/sqlite3/operations.py - About 4 hrs to fix

    BaseExpression has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BaseExpression:
        """Base class for all query expressions."""
    
        empty_result_set_value = NotImplemented
        # aggregate specific fields
    Severity: Minor
    Found in django/db/models/expressions.py - About 4 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if (old_type is None and old_field.remote_field is None) or (
                  new_type is None and new_field.remote_field is None
              ):
                  raise ValueError(
                      "Cannot alter field %s into %s - they do not properly define "
      Severity: Critical
      Found in django/db/backends/base/schema.py - About 4 hrs to fix

        GEOSCoordSeq has 34 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class GEOSCoordSeq(GEOSBase):
            "The internal representation of a list of coordinates inside a Geometry."
        
            ptr_type = CS_PTR
        
        
        Severity: Minor
        Found in django/contrib/gis/geos/coordseq.py - About 4 hrs to fix

          File templates.py has 344 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import argparse
          import mimetypes
          import os
          import posixpath
          import shutil
          Severity: Minor
          Found in django/core/management/templates.py - About 4 hrs to fix

            Function get_traceback_frame_variables has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_traceback_frame_variables(self, request, tb_frame):
                    """
                    Replace the values of variables marked as sensitive with
                    stars (*********).
                    """
            Severity: Minor
            Found in django/views/debug.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 rename_field has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                def rename_field(self, app_label, model_name, old_name, new_name):
                    model_key = app_label, model_name
                    model_state = self.models[model_key]
                    # Rename the field.
                    fields = model_state.fields
            Severity: Minor
            Found in django/db/migrations/state.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_select has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_select(self, with_col_aliases=False):
                    """
                    Return three values:
                    - a list of 3-tuples of (expression, (sql, params), alias)
                    - a klass_info structure,
            Severity: Minor
            Found in django/db/models/sql/compiler.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 lookup_field has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

            def lookup_field(name, obj, model_admin=None):
                opts = obj._meta
                try:
                    f = _get_non_gfk_field(opts, name)
                except (FieldDoesNotExist, FieldIsAForeignKeyColumnName):
            Severity: Minor
            Found in django/contrib/admin/utils.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 _populate has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                def _populate(self):
                    # Short-circuit if called recursively in this thread to prevent
                    # infinite recursion. Concurrent threads may call this at the same
                    # time and will need to continue, so set 'populating' on a
                    # thread-local variable.
            Severity: Minor
            Found in django/urls/resolvers.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 __init__.py has 343 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import functools
            import os
            import pkgutil
            import sys
            from argparse import (
            Severity: Minor
            Found in django/core/management/__init__.py - About 4 hrs to fix

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

              """
              Form classes
              """
              
              import copy
              Severity: Minor
              Found in django/forms/forms.py - About 4 hrs to fix

                File datetime.py has 341 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from datetime import datetime
                
                from django.conf import settings
                from django.db.models.expressions import Func
                from django.db.models.fields import (
                Severity: Minor
                Found in django/db/models/functions/datetime.py - About 4 hrs to fix

                  File csrf.py has 340 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """
                  Cross Site Request Forgery Middleware.
                  
                  This module provides a middleware that implements protection
                  against request forgeries from other sites.
                  Severity: Minor
                  Found in django/middleware/csrf.py - About 4 hrs to fix

                    Function timesince has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def timesince(d, now=None, reversed=False, time_strings=None, depth=2):
                        """
                        Take two datetime objects and return the time between d and now as a nicely
                        formatted string, e.g. "10 minutes". If d occurs after now, return
                        "0 minutes".
                    Severity: Minor
                    Found in django/utils/timesince.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 patch_cache_control has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def patch_cache_control(response, **kwargs):
                        """
                        Patch the Cache-Control header by adding all keyword arguments to it.
                        The transformation is as follows:
                    
                    
                    Severity: Minor
                    Found in django/utils/cache.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_renamed_models has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def generate_renamed_models(self):
                            """
                            Find any renamed models, generate the operations for them, and remove
                            the old entry from the model lists. Must be run before other
                            model-level generation.
                    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 resolve_ref has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def resolve_ref(self, name, allow_joins=True, reuse=None, summarize=False):
                            annotation = self.annotations.get(name)
                            if annotation is not None:
                                if not allow_joins:
                                    for alias in self._gen_col_aliases([annotation]):
                    Severity: Minor
                    Found in django/db/models/sql/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 set_values has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def set_values(self, fields):
                            self.select_related = False
                            self.clear_deferred_loading()
                            self.clear_select_fields()
                            self.has_select_fields = True
                    Severity: Minor
                    Found in django/db/models/sql/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

                    Severity
                    Category
                    Status
                    Source
                    Language