django/django

View on GitHub
django/contrib/gis/db/models/functions.py

Summary

Maintainability
C
1 day
Test Coverage

File functions.py has 451 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from decimal import Decimal

from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
from django.contrib.gis.db.models.sql import AreaField, DistanceField
from django.contrib.gis.geos import GEOSGeometry
Severity: Minor
Found in django/contrib/gis/db/models/functions.py - About 6 hrs to fix

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

        def __init__(self, *expressions, **extra):
            super().__init__(*expressions, **extra)
    
            # Ensure that value expressions are geometric.
            for pos in self.geom_param_pos:
    Severity: Minor
    Found in django/contrib/gis/db/models/functions.py - About 1 hr 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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, expression, x, y, z=0.0, **extra):
    Severity: Minor
    Found in django/contrib/gis/db/models/functions.py - About 35 mins to fix

      Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, expression, bbox=False, crs=False, precision=8, **extra):
      Severity: Minor
      Found in django/contrib/gis/db/models/functions.py - About 35 mins to fix

        Function resolve_expression has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def resolve_expression(self, *args, **kwargs):
                res = super().resolve_expression(*args, **kwargs)
                if not self.geom_param_pos:
                    return res
        
        
        Severity: Minor
        Found in django/contrib/gis/db/models/functions.py - About 35 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

        There are no issues that match your filters.

        Category
        Status