django/django

View on GitHub

Showing 1,784 of 2,092 total issues

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

class OGRGeometry(GDALBase):
    """Encapsulate an OGR geometry."""

    destructor = capi.destroy_geom

Severity: Major
Found in django/contrib/gis/gdal/geometries.py - About 1 day to fix

    File response.py has 554 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import datetime
    import io
    import json
    import mimetypes
    import os
    Severity: Major
    Found in django/http/response.py - About 1 day to fix

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

          def collect(
              self,
              objs,
              source=None,
              nullable=False,
      Severity: Minor
      Found in django/db/models/deletion.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 debug.py has 548 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import functools
      import inspect
      import itertools
      import re
      import sys
      Severity: Major
      Found in django/views/debug.py - About 1 day to fix

        Function generate_created_models has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
        Open

            def generate_created_models(self):
                """
                Find all new models (both managed and unmanaged) and make create
                operations for them as well as separate operations to create any
                foreign key or M2M relationships (these are optimized later, if
        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 names_to_path has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
        Open

            def names_to_path(self, names, opts, allow_many=True, fail_on_missing=False):
                """
                Walk the list of names and turns them into PathInfo tuples. A single
                name in 'names' can generate multiple PathInfos (m2m, for example).
        
        
        Severity: Minor
        Found in django/db/models/sql/query.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 hashers.py has 545 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import base64
        import binascii
        import functools
        import hashlib
        import importlib
        Severity: Major
        Found in django/contrib/auth/hashers.py - About 1 day to fix

          File multipartparser.py has 544 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """
          Multi-part parsing for file uploads.
          
          Exposes one class, ``MultiPartParser``, which feeds chunks of uploaded data to
          file upload handlers for processing.
          Severity: Major
          Found in django/http/multipartparser.py - About 1 day to fix

            File layermapping.py has 539 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # LayerMapping -- A Django Model/OGR Layer Mapping Utility
            """
             The LayerMapping class provides a way to map the contents of OGR
             vector files (e.g. SHP files) to Geographic-enabled Django models.
            
            
            Severity: Major
            Found in django/contrib/gis/utils/layermapping.py - About 1 day to fix

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

                  def get_aggregation(self, using, aggregate_exprs):
                      """
                      Return the dictionary with the values of the existing aggregations.
                      """
                      if not aggregate_exprs:
              Severity: Minor
              Found in django/db/models/sql/query.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 detect_soft_applied has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
              Open

                  def detect_soft_applied(self, project_state, migration):
                      """
                      Test whether a migration has been implicitly applied - that the
                      tables or columns it would create exist. This is intended only for use
                      on initial migrations (as it only looks for CreateModel and AddField).
              Severity: Minor
              Found in django/db/migrations/executor.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 validators.py has 524 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import ipaddress
              import math
              import re
              from pathlib import Path
              from urllib.parse import urlsplit, urlunsplit
              Severity: Major
              Found in django/core/validators.py - About 1 day to fix

                File autoreload.py has 522 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import itertools
                import logging
                import os
                import signal
                import subprocess
                Severity: Major
                Found in django/utils/autoreload.py - About 1 day to fix

                  File main.py has 518 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import warnings
                  from datetime import datetime, timedelta
                  
                  from django import forms
                  from django.conf import settings
                  Severity: Major
                  Found in django/contrib/admin/views/main.py - About 1 day to fix

                    Function serialize has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def serialize(self):
                            def _write(_arg_name, _arg_value):
                                if _arg_name in self.operation.serialization_expand_args and isinstance(
                                    _arg_value, (list, tuple, dict)
                                ):
                    Severity: Minor
                    Found in django/db/migrations/writer.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 utils.py has 505 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import datetime
                    import decimal
                    import json
                    from collections import defaultdict
                    from functools import reduce
                    Severity: Major
                    Found in django/contrib/admin/utils.py - About 1 day to fix

                      File json.py has 501 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import json
                      
                      from django import forms
                      from django.core import checks, exceptions
                      from django.db import NotSupportedError, connections, router
                      Severity: Major
                      Found in django/db/models/fields/json.py - About 1 day to fix

                        File i18n.py has 498 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        from decimal import Decimal
                        
                        from django.conf import settings
                        from django.template import Library, Node, TemplateSyntaxError, Variable
                        from django.template.base import TokenType, render_value_in_context
                        Severity: Minor
                        Found in django/templatetags/i18n.py - About 7 hrs to fix

                          Function sort_dependencies has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def sort_dependencies(app_list, allow_cycles=False):
                              """Sort a list of (app_config, models) pairs into a single list of models.
                          
                              The single list of models is sorted so that any model with a natural key
                              is serialized before a normal model, and any model with a natural key
                          Severity: Minor
                          Found in django/core/serializers/__init__.py - About 7 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 trans_real.py has 493 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          """Translation helper functions."""
                          
                          import functools
                          import gettext as gettext_module
                          import os
                          Severity: Minor
                          Found in django/utils/translation/trans_real.py - About 7 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language