django/django

View on GitHub

Showing 1,786 of 2,094 total issues

File introspection.py has 390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import namedtuple

from django.db import models
from django.db.backends.base.introspection import BaseDatabaseIntrospection
from django.db.backends.base.introspection import FieldInfo as BaseFieldInfo
Severity: Minor
Found in django/db/backends/oracle/introspection.py - About 5 hrs to fix

    DatabaseOperations has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DatabaseOperations(BaseDatabaseOperations):
        cast_char_field_without_max_length = "varchar"
        explain_prefix = "EXPLAIN"
        explain_options = frozenset(
            [
    Severity: Minor
    Found in django/db/backends/postgresql/operations.py - About 5 hrs to fix

      SessionBase has 40 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class SessionBase:
          """
          Base class for all Session classes.
          """
      
      
      Severity: Minor
      Found in django/contrib/sessions/backends/base.py - About 5 hrs to fix

        Function resolve has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

            def resolve(self, context, ignore_failures=False):
                if self.is_var:
                    try:
                        obj = self.var.resolve(context)
                    except VariableDoesNotExist:
        Severity: Minor
        Found in django/template/base.py - About 5 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 flatten_result has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

        def flatten_result(source):
            """
            Turn the given source sequence into a list of reg-exp possibilities and
            their arguments. Return a list of strings and a list of argument lists.
            Each of the two lists will be of the same length.
        Severity: Minor
        Found in django/utils/regex_helper.py - About 5 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 query_utils.py has 383 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        Various data structures used in query construction.
        
        Factored out from django.db.models.query to avoid making the main module very
        large and/or so that they can be used by other modules without getting into
        Severity: Minor
        Found in django/db/models/query_utils.py - About 5 hrs to fix

          Function formset has 129 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              $.fn.formset = function(opts) {
                  const options = $.extend({}, $.fn.formset.defaults, opts);
                  const $this = $(this);
                  const $parent = $this.parent();
                  const updateElementIndex = function(el, prefix, ndx) {
          Severity: Major
          Found in django/contrib/admin/static/admin/js/inlines.js - About 5 hrs to fix

            Function create_altered_indexes has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                def create_altered_indexes(self):
                    option_name = operations.AddIndex.option_name
                    self.renamed_index_together_values = defaultdict(list)
            
                    for app_label, model_name in sorted(self.kept_model_keys):
            Severity: Minor
            Found in django/db/migrations/autodetector.py - About 5 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_order_by has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_order_by(self):
                    """
                    Return a list of 2-tuples of the form (expr, (sql, params, is_ref)) for
                    the ORDER BY clause.
            
            
            Severity: Minor
            Found in django/db/models/sql/compiler.py - About 5 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 delete has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                def delete(self):
                    # sort instance collections
                    for model, instances in self.data.items():
                        self.data[model] = sorted(instances, key=attrgetter("pk"))
            
            
            Severity: Minor
            Found in django/db/models/deletion.py - About 5 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 has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                def validate(self, model, instance, exclude=None, using=DEFAULT_DB_ALIAS):
                    queryset = model._default_manager.using(using)
                    replacement_map = instance._get_field_value_map(
                        meta=model._meta, exclude=exclude
                    )
            Severity: Minor
            Found in django/contrib/postgres/constraints.py - About 5 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 migration_progress_callback has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                def migration_progress_callback(self, action, migration=None, fake=False):
                    if self.verbosity >= 1:
                        compute_time = self.verbosity > 1
                        if action == "apply_start":
                            if compute_time:
            Severity: Minor
            Found in django/core/management/commands/migrate.py - About 5 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 schema.py has 378 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import copy
            from decimal import Decimal
            
            from django.apps.registry import Apps
            from django.db import NotSupportedError
            Severity: Minor
            Found in django/db/backends/sqlite3/schema.py - About 5 hrs to fix

              File dispatcher.py has 377 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import asyncio
              import logging
              import threading
              import weakref
              
              
              Severity: Minor
              Found in django/dispatch/dispatcher.py - About 5 hrs to fix

                File introspection.py has 372 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from collections import namedtuple
                
                import sqlparse
                
                from django.db import DatabaseError
                Severity: Minor
                Found in django/db/backends/sqlite3/introspection.py - About 4 hrs to fix

                  Function reverse has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None):
                      if urlconf is None:
                          urlconf = get_urlconf()
                      resolver = get_resolver(urlconf)
                      args = args or []
                  Severity: Minor
                  Found in django/urls/base.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 call_command has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def call_command(command_name, *args, **options):
                      """
                      Call the given command, with the given options and args/kwargs.
                  
                      This is the primary API you should use for calling specific commands.
                  Severity: Minor
                  Found in django/core/management/__init__.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 process_locale_dir has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def process_locale_dir(self, locale_dir, files):
                          """
                          Extract translatable literals from the specified files, creating or
                          updating the POT file for a given locale directory.
                  
                  
                  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 feedgenerator.py has 369 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """
                  Syndication feed generation library -- used for generating RSS, etc.
                  
                  Sample usage:
                  
                  
                  Severity: Minor
                  Found in django/utils/feedgenerator.py - About 4 hrs to fix

                    File operations.py has 366 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import uuid
                    
                    from django.conf import settings
                    from django.db.backends.base.operations import BaseDatabaseOperations
                    from django.db.backends.utils import split_tzname_delta
                    Severity: Minor
                    Found in django/db/backends/mysql/operations.py - About 4 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language