django/django

View on GitHub

Showing 1,615 of 2,108 total issues

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

    def as_sql(self, with_limits=True, with_col_aliases=False):
        """
        Create the SQL for this query. Return the SQL string and list of
        parameters.

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

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

Function handle_inspection has a Cognitive Complexity of 65 (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 geometry.py has 590 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    File makemessages.py has 578 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

      File __init__.py has 573 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

        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

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

            def handle(self, **options):
        
                self.verbosity = options['verbosity']
                self.interactive = options['interactive']
                app_label = options['app_label']
        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

        ModelAdmin has 65 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ModelAdmin(BaseModelAdmin):
            """Encapsulate all admin options and functionality for a given model."""
        
            list_display = ('__str__',)
            list_display_links = ()
        Severity: Major
        Found in django/contrib/admin/options.py - About 1 day to fix

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

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

            Function _check_relationship_model has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
            Open

                def _check_relationship_model(self, from_model=None, **kwargs):
                    if hasattr(self.remote_field.through, '_meta'):
                        qualified_model_name = "%s.%s" % (
                            self.remote_field.through._meta.app_label, self.remote_field.through.__name__)
                    else:
            Severity: Minor
            Found in django/db/models/fields/related.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 dates.py has 558 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 fields.py has 554 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              from collections import defaultdict
              
              from django.contrib.contenttypes.models import ContentType
              from django.core import checks
              from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist
              Severity: Major
              Found in django/contrib/contenttypes/fields.py - About 1 day to fix

                Function from_model has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
                Open

                    def from_model(cls, model, exclude_rels=False):
                        """Given a model, return a ModelState representing it."""
                        # Deconstruct the fields
                        fields = []
                        for field in model._meta.local_fields:
                Severity: Minor
                Found in django/db/migrations/state.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 urlize has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
                Open

                def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
                    """
                    Convert any URLs in text into clickable links.
                
                    Works on http://, https://, www. links, and also on links ending in one of
                Severity: Minor
                Found in django/utils/html.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 537 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 geometries.py has 535 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """
                   The OGRGeometry is a wrapper for using the OGR Geometry class
                   (see https://www.gdal.org/classOGRGeometry.html).  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

                    Function items_for_result has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def items_for_result(cl, result, form):
                        """
                        Generate the actual list of data.
                        """
                    
                    
                    Severity: Minor
                    Found in django/contrib/admin/templatetags/admin_list.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 dump has 218 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    QUnit.dump = ( function() {
                        function quote( str ) {
                            return "\"" + str.toString().replace( /\\/g, "\\\\" ).replace( /"/g, "\\\"" ) + "\"";
                        }
                        function literal( o ) {
                    Severity: Major
                    Found in js_tests/qunit/qunit.js - About 1 day to fix

                      OGRGeometry has 60 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class OGRGeometry(GDALBase):
                          """Encapsulate an OGR geometry."""
                          destructor = capi.destroy_geom
                      
                          def __init__(self, geom_input, srs=None):
                      Severity: Major
                      Found in django/contrib/gis/gdal/geometries.py - About 1 day to fix
                        Severity
                        Category
                        Status
                        Source
                        Language