django/django

View on GitHub

Showing 2,090 of 2,090 total issues

File base.py has 589 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Base classes for writing management commands (named commands which can
be executed through ``django-admin`` or ``manage.py``).
"""

Severity: Major
Found in django/core/management/base.py - About 1 day to fix

    Function _reverse_with_prefix has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    Open

        def _reverse_with_prefix(self, lookup_view, _prefix, *args, **kwargs):
            if args and kwargs:
                raise ValueError("Don't mix *args and **kwargs in call to reverse()!")
    
            if not self._populated:
    Severity: Minor
    Found in django/urls/resolvers.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 request.py has 579 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import codecs
    import copy
    from io import BytesIO
    from itertools import chain
    from urllib.parse import parse_qsl, quote, urlencode, urljoin, urlsplit
    Severity: Major
    Found in django/http/request.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

      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
                          Severity
                          Category
                          Status
                          Source
                          Language