django/django

View on GitHub
django/contrib/gis/geos/geometry.py

Summary

Maintainability
F
4 days
Test Coverage

GEOSGeometryBase has 81 functions (exceeds 20 allowed). Consider refactoring.
Open

class GEOSGeometryBase(GEOSBase):

    _GEOS_CLASSES = None

    ptr_type = GEOM_PTR
Severity: Major
Found in django/contrib/gis/geos/geometry.py - About 1 day to fix

    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

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

          def __init__(self, geo_input, srid=None):
              """
              The base constructor for GEOS geometry objects. It may take the
              following inputs:
      
      
      Severity: Minor
      Found in django/contrib/gis/geos/geometry.py - About 2 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

      Function transform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def transform(self, ct, clone=False):
              """
              Requires GDAL. Transform the geometry according to the given
              transformation object, which may be an integer SRID, and WKT or
              PROJ.4 string. By default, transform the geometry in-place and return
      Severity: Minor
      Found in django/contrib/gis/geos/geometry.py - About 55 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 buffer_with_style has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def buffer_with_style(self, width, quadsegs=8, end_cap_style=1, join_style=1, mitre_limit=5.0):
      Severity: Minor
      Found in django/contrib/gis/geos/geometry.py - About 35 mins to fix

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

            def __init__(self, ptr, cls):
                self._ptr = ptr
        
                # Setting the class type (e.g., Point, Polygon, etc.)
                if type(self) in (GEOSGeometryBase, GEOSGeometry):
        Severity: Minor
        Found in django/contrib/gis/geos/geometry.py - About 25 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def project(self, point):
                from .point import Point
                if not isinstance(point, Point):
                    raise TypeError('locate_point argument must be a Point')
                return capi.geos_project(self.ptr, point.ptr)
        Severity: Major
        Found in django/contrib/gis/geos/geometry.py and 1 other location - About 1 hr to fix
        django/contrib/gis/geos/geometry.py on lines 656..660

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 44.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def project_normalized(self, point):
                from .point import Point
                if not isinstance(point, Point):
                    raise TypeError('locate_point argument must be a Point')
                return capi.geos_project_normalized(self.ptr, point.ptr)
        Severity: Major
        Found in django/contrib/gis/geos/geometry.py and 1 other location - About 1 hr to fix
        django/contrib/gis/geos/geometry.py on lines 650..654

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 44.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            @property
            def hex(self):
                """
                Return the WKB of this Geometry in hexadecimal form. Please note
                that the SRID is not included in this representation because it is not
        Severity: Minor
        Found in django/contrib/gis/geos/geometry.py and 1 other location - About 40 mins to fix
        django/contrib/gis/geos/geometry.py on lines 373..380

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 34.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            @property
            def hexewkb(self):
                """
                Return the EWKB of this Geometry in hexadecimal form. This is an
                extension of the WKB specification that includes SRID value that are
        Severity: Minor
        Found in django/contrib/gis/geos/geometry.py and 1 other location - About 40 mins to fix
        django/contrib/gis/geos/geometry.py on lines 362..371

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 34.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            @property
            def ewkb(self):
                """
                Return the EWKB representation of this Geometry as a Python buffer.
                This is an extension of the WKB specification that includes any SRID
        Severity: Minor
        Found in django/contrib/gis/geos/geometry.py and 1 other location - About 30 mins to fix
        django/contrib/gis/geos/geometry.py on lines 390..397

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 32.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            @property
            def wkb(self):
                """
                Return the WKB (Well-Known Binary) representation of this Geometry
                as a Python buffer.  SRID and Z values are not included, use the
        Severity: Minor
        Found in django/contrib/gis/geos/geometry.py and 1 other location - About 30 mins to fix
        django/contrib/gis/geos/geometry.py on lines 399..406

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 32.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        There are no issues that match your filters.

        Category
        Status