django/django

View on GitHub

Showing 1,786 of 2,094 total issues

Function create has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create(cls, field, request, params, model, model_admin, field_path):
Severity: Minor
Found in django/contrib/admin/filters.py - About 45 mins to fix

    Function to_python has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_python(self, value):
            if not value:
                return {}
            if not isinstance(value, dict):
                try:
    Severity: Minor
    Found in django/contrib/postgres/forms/hstore.py - About 45 mins 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 clean has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def clean(self, value):
            cleaned_data = []
            errors = []
            if not any(value) and self.required:
                raise ValidationError(self.error_messages["required"])
    Severity: Minor
    Found in django/contrib/postgres/forms/array.py - About 45 mins 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

    Avoid deeply nested control flow statements.
    Open

                            if isinstance(expr, F) and expr.name in exclude:
                                return
                rhs_expression = expression.replace_expressions(replacements)
    Severity: Major
    Found in django/contrib/postgres/constraints.py - About 45 mins to fix

      Function process_rhs_params has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_rhs_params(self):
              if self.rhs_params:
                  # Check if a band index was passed in the query argument.
                  if len(self.rhs_params) == (2 if self.lookup_name == "relate" else 1):
                      self.process_band_indices()
      Severity: Minor
      Found in django/contrib/gis/db/models/lookups.py - About 45 mins 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 transform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def transform(
              self, srs, driver=None, name=None, resampling="NearestNeighbour", max_error=0.0
          ):
              """
              Return a copy of this raster reprojected into the given spatial
      Severity: Minor
      Found in django/contrib/gis/gdal/raster/source.py - About 45 mins 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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, x=None, y=None, z=None, srid=None):
              """
              The Point object may be initialized with either a tuple, or individual
              parameters.
      
      
      Severity: Minor
      Found in django/contrib/gis/geos/point.py - About 45 mins 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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, dr_input):
              """
              Initialize an GDAL/OGR driver on either a string or integer input.
              """
              if isinstance(dr_input, str):
      Severity: Minor
      Found in django/contrib/gis/gdal/driver.py - About 45 mins 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_postgresql has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def as_postgresql(self, compiler, connection, **extra_context):
              clone = self.copy()
              function = None
              expr2 = clone.source_expressions[1]
              geography = self.source_is_geography()
      Severity: Minor
      Found in django/contrib/gis/db/models/functions.py - About 45 mins 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 _alter_column_type_sql has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _alter_column_type_sql(
      Severity: Minor
      Found in django/contrib/gis/db/backends/postgis/schema.py - About 45 mins to fix

        Function metadata has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def metadata(self, value):
                """
                Set the metadata. Update only the domains that are contained in the
                value dictionary.
                """
        Severity: Minor
        Found in django/contrib/gis/gdal/raster/base.py - About 45 mins 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

        Avoid deeply nested control flow statements.
        Open

                            if isinstance(val, str):
                                val_fmt = ' ("%s")'
                            else:
                                val_fmt = " (%s)"
                            output += val_fmt % val
        Severity: Major
        Found in django/contrib/gis/utils/ogrinfo.py - About 45 mins to fix

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

              def __init__(self, path=None, cache=0, country=None, city=None):
                  """
                  Initialize the GeoIP object. No parameters are required to use default
                  settings. Keyword arguments may be passed in to customize the locations
                  of the GeoIP datasets.
          Severity: Minor
          Found in django/contrib/gis/geoip2.py - About 45 mins 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 __getitem__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __getitem__(self, index):
                  "Allows use of the index [] operator to get a layer at the index."
                  if isinstance(index, str):
                      try:
                          layer = capi.get_layer_by_name(self.ptr, force_bytes(index))
          Severity: Minor
          Found in django/contrib/gis/gdal/datasource.py - About 45 mins 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 add_srs_entry has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def add_srs_entry(
              srs, auth_name="EPSG", auth_srid=None, ref_sys_name=None, database=None
          ):
              """
              Take a GDAL SpatialReference system and add its information to the
          Severity: Minor
          Found in django/contrib/gis/utils/srs.py - About 45 mins 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 __set__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __set__(self, instance, value):
                  """
                  Retrieve the proxied geometry or raster with the corresponding class
                  specified during initialization.
          
          
          Severity: Minor
          Found in django/contrib/gis/db/models/proxy.py - About 45 mins 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 kml has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS):
          Severity: Minor
          Found in django/contrib/gis/sitemaps/views.py - About 45 mins to fix

            Function feature_kwargs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def feature_kwargs(self, feat):
                    """
                    Given an OGR Feature, return a dictionary of keyword arguments for
                    constructing the mapped model.
                    """
            Severity: Minor
            Found in django/contrib/gis/utils/layermapping.py - About 45 mins 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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, *args, **kwargs):
                    if self.support_js_module_import_aggregation:
                        self.patterns += (self._js_module_import_aggregation_patterns,)
                    super().__init__(*args, **kwargs)
                    self._patterns = {}
            Severity: Minor
            Found in django/contrib/staticfiles/storage.py - About 45 mins 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_domain has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_domain(self, site=None):
                    # Determine domain
                    if site is None:
                        if django_apps.is_installed("django.contrib.sites"):
                            Site = django_apps.get_model("sites.Site")
            Severity: Minor
            Found in django/contrib/sitemaps/__init__.py - About 45 mins 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