django/django

View on GitHub

Showing 1,637 of 2,124 total issues

Function normalize has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

def normalize(pattern):
    r"""
    Given a reg-exp pattern, normalize it to an iterable of forms that
    suffice for reverse matching. This does the following:

Severity: Minor
Found in django/utils/regex_helper.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 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

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

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

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

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

              def __init__(self, *args, **kwargs):
                  # Alias some things as locals to avoid repeat global lookups
                  cls = self.__class__
                  opts = self._meta
                  _setattr = setattr
          Severity: Minor
          Found in django/db/models/base.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 get_order_by has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_order_by(self):
                  """
                  Return a list of 2-tuples of form (expr, (sql, params, is_ref)) for the
                  ORDER BY clause.
          
          
          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 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

              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

                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

                File resolvers.py has 547 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

                  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

                  Function _check_relationship_model has a Cognitive Complexity of 58 (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

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

                      def handle(self, app_or_project, name, target=None, **options):
                          self.app_or_project = app_or_project
                          self.a_or_an = 'an' if app_or_project == 'app' else 'a'
                          self.paths_to_remove = []
                          self.verbosity = options['verbosity']
                  Severity: Minor
                  Found in django/core/management/templates.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 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

                    Severity
                    Category
                    Status
                    Source
                    Language