Terralego/django-geostore

View on GitHub

Showing 30 of 65 total issues

Function parse_element has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_element(self, element):
        mapping = {
            'point': 'newpoint',
            'linestring': 'newlinestring',
            'polygon': 'newpolygon'
Severity: Minor
Found in geostore/renderers.py - About 5 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

File __init__.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
from copy import deepcopy

from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.geos import GEOSException, GEOSGeometry
Severity: Minor
Found in geostore/views/__init__.py - About 2 hrs to fix

    Function handle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            layer_pk = options.get('layer_pk')
            layer_name = options.get('layer_name') or uuid.uuid4()
            file_path = options.get('file_path')
            dryrun = options.get('dry_run')
    Severity: Minor
    Found in geostore/management/commands/import_geojson.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 handle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            layer_pk = options.get('layer_pk')
            layer_name = options.get('layer-name') or uuid.uuid4()
            file_path = options.get('file_path')
            dryrun = options.get('dry_run')
    Severity: Minor
    Found in geostore/management/commands/import_shapefile.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 make_zipfile_bytesio has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def make_zipfile_bytesio(base_dir):
        zip_file = io.BytesIO()
    
        with zipfile.ZipFile(zip_file, "w",
                             compression=zipfile.ZIP_DEFLATED) as zf:
    Severity: Minor
    Found in geostore/import_export/helpers.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 to_shapefile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_shapefile(self):
            if not self.features.count():
                return
            with TemporaryDirectory() as shape_folder:
                shapes = {}
    Severity: Minor
    Found in geostore/import_export/exports.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 from_csv_dictreader has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def from_csv_dictreader(self, reader, pk_properties, options, operations,
    Severity: Major
    Found in geostore/import_export/imports.py - About 1 hr to fix

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

          def filter_queryset(self, request, queryset, view):
              query = Q()
              for param_name, param_value in request.query_params.items():
                  try:
                      field = (queryset.model
      Severity: Minor
      Found in geostore/filters.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 _initial_import_from_csv has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _initial_import_from_csv(self, chunks, options, operations):
              for chunk in chunks:
                  entries = []
                  for row in chunk:
                      feature_args = {
      Severity: Minor
      Found in geostore/import_export/imports.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 _get_layer_out has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_layer_out(self, pk, name, clear_output, verbosity):
              if pk or name:
                  layer = self._get_layer_by_pk(pk) if pk else self._get_layer_by_name(name)
                  if clear_output:
                      layer.features.all().delete()
      Severity: Minor
      Found in geostore/management/commands/layer_processing.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 handle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle(self, *args, **options):
              for layer in Layer.objects.all():
                  if options['verbosity'] >= 1:
                      self.stdout.write(f'Generating {layer.name} tiles cache')
                  bbox = layer.features.aggregate(bbox=Extent('geom'))['bbox']
      Severity: Minor
      Found in geostore/management/commands/fill_tiles_cache.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 len(simple_object_coords) > 1:
                                  # manage holes
                                  polygon.innerboundaryis = (simple_object_coords[1], )
                          else:
      Severity: Major
      Found in geostore/renderers.py - About 45 mins to fix

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

            def handle(self, *args, **options):
                query = options.get('query')
                layer_name = options.get('layer') or uuid.uuid4()
                type_features = options.get('type')
                layer_pk = options.get('layer_pk')
        Severity: Minor
        Found in geostore/management/commands/import_osm.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_tile_for_layer has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def get_tile_for_layer(self, layer, z, x, y, name=None, features_pk=None):
        Severity: Minor
        Found in geostore/tiles/mixins.py - About 45 mins to fix

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

              def wrapper(self, x, y, z,
          Severity: Minor
          Found in geostore/tiles/helpers.py - About 45 mins to fix

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

                def from_shapefile(self, zipped_shapefile_file, id_field=None):
                    """ Load ShapeFile content provided into a zipped archive.
            
                    zipped_shapefile_file -- a file-like object on the zipped content
                    id_field -- the field name used a identifier
            Severity: Minor
            Found in geostore/import_export/imports.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 _complementary_import_from_csv has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def _complementary_import_from_csv(self, chunks, options, operations,
            Severity: Minor
            Found in geostore/import_export/imports.py - About 45 mins to fix

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

                  def _get_layer_out(self, pk, name, clear_output, verbosity):
              Severity: Minor
              Found in geostore/management/commands/layer_processing.py - About 35 mins to fix

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

                    def extra_geometry(self, request, id_extra_feature, *args, **kwargs):
                Severity: Minor
                Found in geostore/views/__init__.py - About 35 mins to fix

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

                      def tiles(self, request, z, x, y, **kwargs):
                  Severity: Minor
                  Found in geostore/tiles/mixins.py - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language