django/django

View on GitHub

Showing 1,784 of 2,092 total issues

File base.py has 888 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 _alter_field has a Cognitive Complexity of 104 (exceeds 5 allowed). Consider refactoring.
    Open

        def _alter_field(
            self,
            model,
            old_field,
            new_field,
    Severity: Minor
    Found in django/db/backends/base/schema.py - About 2 days 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 99 (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

    Function handle has a Cognitive Complexity of 99 (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 handle_inspection has a Cognitive Complexity of 96 (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 801 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      File state.py has 791 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import copy
      from collections import defaultdict
      from contextlib import contextmanager
      from functools import partial
      
      
      Severity: Major
      Found in django/db/migrations/state.py - About 1 day to fix

        Function handle has a Cognitive Complexity of 93 (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

        File defaultfilters.py has 765 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Default variable filters."""
        
        import random as random_module
        import re
        import types
        Severity: Major
        Found in django/template/defaultfilters.py - About 1 day to fix

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

          class QuerySet(AltersData):
              """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

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

            class Query(BaseExpression):
                """A single SQL query."""
            
                alias_prefix = "T"
                empty_result_set_value = None
            Severity: Major
            Found in django/db/models/sql/query.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

              Function make_middleware_decorator has a Cognitive Complexity of 80 (exceeds 5 allowed). Consider refactoring.
              Open

              def make_middleware_decorator(middleware_class):
                  def _make_decorator(*m_args, **m_kwargs):
                      def _decorator(view_func):
                          middleware = middleware_class(view_func, *m_args, **m_kwargs)
              
              
              Severity: Minor
              Found in django/utils/decorators.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 resolvers.py has 693 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """
              This module converts requested URLs to callback view functions.
              
              URLResolver is the main class here. Its resolve() method takes a URL (as
              a string) and returns a ResolverMatch object which provides access to all
              Severity: Major
              Found in django/urls/resolvers.py - About 1 day to fix

                File makemessages.py has 688 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import glob
                import os
                import re
                import sys
                from functools import total_ordering
                Severity: Major
                Found in django/core/management/commands/makemessages.py - About 1 day to fix

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

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

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

                    import datetime
                    import decimal
                    import json
                    import warnings
                    from importlib import import_module
                    Severity: Major
                    Found in django/db/backends/base/operations.py - About 1 day to fix

                      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

                      File fields.py has 669 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import functools
                      import itertools
                      import warnings
                      from collections import defaultdict
                      
                      
                      Severity: Major
                      Found in django/contrib/contenttypes/fields.py - About 1 day to fix

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

                            def _order_by_pairs(self):
                                if self.query.extra_order_by:
                                    ordering = self.query.extra_order_by
                                elif not self.query.default_ordering:
                                    ordering = self.query.order_by
                        Severity: Minor
                        Found in django/db/models/sql/compiler.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