Terralego/django-geostore

View on GitHub

Showing 64 of 65 total issues

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

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

              def get_tile(self, x, y, z, name=None, features_pks=None):
          Severity: Minor
          Found in geostore/tiles/helpers.py - About 35 mins to fix

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

                def _import_row_from_csv(self, row, pk_properties, operations, options):
            Severity: Minor
            Found in geostore/import_export/imports.py - About 35 mins to fix

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

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

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

                    def _call(self, python_callable_name, layer_ins, layer_out, **command_args):
                Severity: Minor
                Found in geostore/management/commands/layer_processing.py - About 35 mins to fix

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

                      def has_object_permission(self, request, view, obj):
                          if request.user.is_superuser:
                              return True
                  
                          has_perm = request.user.has_perm('geostore.can_manage_layers')
                  Severity: Minor
                  Found in geostore/permissions.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

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

                      def sync_relations(self, layer_relation=None):
                          """ replace feature relations for automatic layer relations """
                          logger.info("Feature relation synchronisation")
                          layer_relations = self.layer.relations_as_origin.exclude(relation_type__isnull=True)
                          layer_relations = layer_relations.filter(pk__in=[layer_relation]) if layer_relation else layer_relations
                  Severity: Minor
                  Found in geostore/models.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

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

                      def get_tile(self, z, x, y):
                          tiles_array = []
                          for layer in self.layers:
                              minzoom = layer.layer_settings_with_default('tiles', 'minzoom')
                              maxzoom = layer.layer_settings_with_default('tiles', 'maxzoom')
                  Severity: Minor
                  Found in geostore/tiles/mixins.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

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

                      def _processing_make_valid(self, layer_ins, layer_out):
                          if len(layer_ins) != 1:
                              raise ValueError('Exactly one input layer required')
                          layer_in = layer_ins[0]
                  
                  
                  Severity: Minor
                  Found in geostore/management/commands/layer_processing.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

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

                      def handle(self, *args, **options):
                          dryrun = options.get('dry_run')
                          sp = transaction.savepoint()
                          layer_ins = self._get_layer_ins(
                              options.get('layer_pk_ins'),
                  Severity: Minor
                  Found in geostore/management/commands/layer_processing.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

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

                      def geom_to_gpx(self, geom, name, description):
                          """Convert a geometry to a gpx entity.
                          Point -> add as a Way Point
                          LineString -> add all Points in a Route
                          Polygon -> add all Points of the external linering in a Route
                  Severity: Minor
                  Found in geostore/renderers.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

                  Standard pseudo-random generators are not suitable for security/cryptographic purposes.
                  Open

                          expiration = int(expiration_factor * (3600 * 24 * 7) * uniform(0.9, 1.1))
                  Severity: Info
                  Found in geostore/tiles/helpers.py by bandit

                  Using xml.etree.ElementTree.fromstring to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree.fromstring with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
                  Open

                              ET.fromstring(response.content)

                  Consider possible security implications associated with subprocess module.
                  Open

                  import subprocess

                  Either merge this branch with the identical one on line "163" or change one of the implementations.
                  Open

                              raise NotImplementedError

                  Having two branches in the same if structure with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.

                  Noncompliant Code Example

                  if 0 <= a < 10:
                      do_the_thing()
                  elif 10 <= a < 20:
                      do_the_other_thing()
                  elif 20 <= a < 50:
                      do_the_thing()  # Noncompliant; duplicates first condition
                  else:
                      do_the_rest()
                  
                  b = 4 if a > 12 else 4
                  

                  Compliant Solution

                  if (0 <= a < 10) or (20 <= a < 50):
                      do_the_thing()
                  elif 10 <= a < 20:
                      do_the_other_thing()
                  else:
                      do_the_rest()
                  
                  b = 4
                  

                  or

                  if 0 <= a < 10:
                      do_the_thing()
                  elif 10 <= a < 20:
                      do_the_other_thing()
                  elif 20 <= a < 50:
                      do_the_third_thing()
                  else:
                      do_the_rest()
                  
                  b = 8 if a > 12 else 4
                  

                  Refactor this function to reduce its Cognitive Complexity from 39 to the 15 allowed.
                  Open

                      def parse_element(self, element):
                  Severity: Critical
                  Found in geostore/renderers.py by sonar-python

                  Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                  See

                  Severity
                  Category
                  Status
                  Source
                  Language