django/django

View on GitHub
django/contrib/gis/gdal/geometries.py

Summary

Maintainability
F
4 days
Test Coverage

File geometries.py has 535 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
 The OGRGeometry is a wrapper for using the OGR Geometry class
 (see https://www.gdal.org/classOGRGeometry.html).  OGRGeometry
 may be instantiated when reading geometries from OGR Data Sources
 (e.g. SHP files), or when given OGC WKT (a string).
Severity: Major
Found in django/contrib/gis/gdal/geometries.py - About 1 day to fix

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

    class OGRGeometry(GDALBase):
        """Encapsulate an OGR geometry."""
        destructor = capi.destroy_geom
    
        def __init__(self, geom_input, srs=None):
    Severity: Major
    Found in django/contrib/gis/gdal/geometries.py - About 1 day to fix

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

          def __init__(self, geom_input, srs=None):
              """Initialize Geometry on either WKT or an OGR pointer as input."""
              str_instance = isinstance(geom_input, str)
      
              # If HEX, unpack input to a binary buffer.
      Severity: Minor
      Found in django/contrib/gis/gdal/geometries.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 add has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def add(self, geom):
              "Add the geometry to this Geometry Collection."
              if isinstance(geom, OGRGeometry):
                  if isinstance(geom, self.__class__):
                      for g in geom:
      Severity: Minor
      Found in django/contrib/gis/gdal/geometries.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 __getitem__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __getitem__(self, index):
              "Return the Point at the given index."
              if 0 <= index < self.point_count:
                  x, y, z = c_double(), c_double(), c_double()
                  capi.get_point(self.ptr, index, byref(x), byref(y), byref(z))
      Severity: Minor
      Found in django/contrib/gis/gdal/geometries.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 __getitem__(self, index):
              "Get the Geometry at the specified index."
              if 0 <= index < self.geom_count:
                  return OGRGeometry(capi.clone_geom(capi.get_geom_ref(self.ptr, index)), self.srs)
              else:
      Severity: Major
      Found in django/contrib/gis/gdal/geometries.py and 1 other location - About 3 hrs to fix
      django/contrib/gis/gdal/geometries.py on lines 600..605

      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 63.

      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 __getitem__(self, index):
              "Get the ring at the specified index."
              if 0 <= index < self.geom_count:
                  return OGRGeometry(capi.clone_geom(capi.get_geom_ref(self.ptr, index)), self.srs)
              else:
      Severity: Major
      Found in django/contrib/gis/gdal/geometries.py and 1 other location - About 3 hrs to fix
      django/contrib/gis/gdal/geometries.py on lines 639..644

      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 63.

      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 4 locations. Consider refactoring.
      Open

          @property
          def point_count(self):
              "Return the number of Points in this Geometry Collection."
              # Summing up the number of points in each geometry in this collection
              return sum(self[i].point_count for i in range(self.geom_count))
      Severity: Major
      Found in django/contrib/gis/gdal/geometries.py and 3 other locations - About 1 hr to fix
      django/contrib/gis/gdal/geometries.py on lines 614..617
      django/contrib/gis/gdal/geometries.py on lines 620..624
      django/contrib/gis/gdal/geometries.py on lines 670..673

      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 40.

      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 4 locations. Consider refactoring.
      Open

          @property
          def tuple(self):
              "Return a tuple representation of this Geometry Collection."
              return tuple(self[i].tuple for i in range(self.geom_count))
      Severity: Major
      Found in django/contrib/gis/gdal/geometries.py and 3 other locations - About 1 hr to fix
      django/contrib/gis/gdal/geometries.py on lines 614..617
      django/contrib/gis/gdal/geometries.py on lines 620..624
      django/contrib/gis/gdal/geometries.py on lines 664..668

      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 40.

      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 _get_srs(self):
              "Return the Spatial Reference for this Geometry."
              try:
                  srs_ptr = capi.get_geom_srs(self.ptr)
                  return SpatialReference(srs_api.clone_srs(srs_ptr))
      Severity: Major
      Found in django/contrib/gis/gdal/geometries.py and 1 other location - About 1 hr to fix
      django/contrib/gis/gdal/layer.py on lines 121..128

      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 40.

      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 4 locations. Consider refactoring.
      Open

          @property
          def tuple(self):
              "Return a tuple of LinearRing coordinate tuples."
              return tuple(self[i].tuple for i in range(self.geom_count))
      Severity: Major
      Found in django/contrib/gis/gdal/geometries.py and 3 other locations - About 1 hr to fix
      django/contrib/gis/gdal/geometries.py on lines 620..624
      django/contrib/gis/gdal/geometries.py on lines 664..668
      django/contrib/gis/gdal/geometries.py on lines 670..673

      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 40.

      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 4 locations. Consider refactoring.
      Open

          @property
          def point_count(self):
              "Return the number of Points in this Polygon."
              # Summing up the number of points in each ring of the Polygon.
              return sum(self[i].point_count for i in range(self.geom_count))
      Severity: Major
      Found in django/contrib/gis/gdal/geometries.py and 3 other locations - About 1 hr to fix
      django/contrib/gis/gdal/geometries.py on lines 614..617
      django/contrib/gis/gdal/geometries.py on lines 664..668
      django/contrib/gis/gdal/geometries.py on lines 670..673

      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 40.

      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