Terralego/django-geostore

View on GitHub

Showing 64 of 65 total issues

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

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

    @receiver(post_save, sender=LayerRelation)
    def save_layer_relation(sender, instance, **kwargs):
        if app_settings.GEOSTORE_RELATION_CELERY_ASYNC:
            execute_async_func(layer_relations_set_destinations, (instance.pk,))
    Severity: Minor
    Found in geostore/signals.py and 1 other location - About 45 mins to fix
    geostore/signals.py on lines 10..13

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

    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

    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 _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 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 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_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 _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 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 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 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 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 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

                  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

                  subprocess call - check for execution of untrusted input.
                  Open

                              proc = subprocess.run(
                                  args=[
                                      'ogr2ogr',
                                      '-f', 'GeoJSON', '/vsistdout/',
                                      tmp_osm.name,

                  Method "from_csv_dictreader" has 8 parameters, which is greater than the 7 authorized.
                  Open

                      def from_csv_dictreader(self, reader, pk_properties, options, operations,
                                              init=False, chunk_size=1000, fast=False):

                  A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

                  Noncompliant Code Example

                  With a maximum number of 4 parameters:

                  def do_something(param1, param2, param3, param4, param5):
                      ...
                  

                  Compliant Solution

                  def do_something(param1, param2, param3, param4):
                      ...
                  

                  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

                  Consider possible security implications associated with subprocess module.
                  Open

                  import subprocess

                  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)
                  Severity
                  Category
                  Status
                  Source
                  Language