inasafe/inasafe

View on GitHub
safe/gis/raster/contour.py

Summary

Maintainability
D
2 days
Test Coverage

File contour.py has 370 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8
"""Create contour from shakemap raster layer."""

import logging
import os
Severity: Minor
Found in safe/gis/raster/contour.py - About 4 hrs to fix

    Function shakemap_contour has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def shakemap_contour(shakemap_layer_path, output_file_path='', active_band=1):
        """Creating contour from a shakemap layer.
    
        :param shakemap_layer_path: The shake map raster layer path.
        :type shakemap_layer_path: basestring
    Severity: Minor
    Found in safe/gis/raster/contour.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                          for l in range(weights.shape[1]):  # NOQA
                              # Get coordinates of tiled_input array that match given
                              # weights
                              m = i + k - hw_row
                              n = j + l - hw_col
      Severity: Major
      Found in safe/gis/raster/contour.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if correction == 0:
                                assert (not overlapping_mask.any())
        
                            # Redistribute to non-masked points.
                            tmp_weights = np.copy(weights)
        Severity: Major
        Found in safe/gis/raster/contour.py - About 45 mins to fix

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

          def create_smooth_contour(
          Severity: Minor
          Found in safe/gis/raster/contour.py - About 35 mins to fix

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

            def smooth_shakemap(
            Severity: Minor
            Found in safe/gis/raster/contour.py - About 35 mins to fix

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

                                  overlapping_mask = tiled_mask[
                                      i - hw_row:i - hw_row + fw_row,
                                      j - hw_col:j - hw_col + fw_row]
              Severity: Major
              Found in safe/gis/raster/contour.py and 1 other location - About 2 hrs to fix
              safe/gis/raster/contour.py on lines 185..187

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

              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

                              overlapping = tiled_input[
                                  i - hw_row:i - hw_row + fw_row,
                                  j - hw_col:j - hw_col + fw_col]
              Severity: Major
              Found in safe/gis/raster/contour.py and 1 other location - About 2 hrs to fix
              safe/gis/raster/contour.py on lines 194..196

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

              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

                  try:
                      gdal.ContourGenerate(
                          shakemap_data.GetRasterBand(active_band),
                          contour_interval,
                          contour_base,
              Severity: Major
              Found in safe/gis/raster/contour.py and 1 other location - About 2 hrs to fix
              safe/gui/tools/shake_grid/shake_grid.py on lines 822..835

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

              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

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

                      tiled_input[i * rows:(i + 1) * rows, -cols:] = \
              Severity: Minor
              Found in safe/gis/raster/contour.py and 1 other location - About 50 mins to fix
              safe/gis/raster/contour.py on lines 93..93

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

              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

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

                          np.fliplr(tiled_input[i * rows:(i + 1) * rows, -cols:])
              Severity: Minor
              Found in safe/gis/raster/contour.py and 1 other location - About 50 mins to fix
              safe/gis/raster/contour.py on lines 92..92

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

              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

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

                          np.flipud(tiled_input[-rows:, i * cols:(i + 1) * cols])
              Severity: Minor
              Found in safe/gis/raster/contour.py and 1 other location - About 50 mins to fix
              safe/gis/raster/contour.py on lines 101..101

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

              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

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

                      tiled_input[-rows:, i * cols:(i + 1) * cols] = \
              Severity: Minor
              Found in safe/gis/raster/contour.py and 1 other location - About 50 mins to fix
              safe/gis/raster/contour.py on lines 102..102

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

              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

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

                          np.flipud(tiled_input[0:rows, i * cols:(i + 1) * cols])
              Severity: Minor
              Found in safe/gis/raster/contour.py and 1 other location - About 40 mins to fix
              safe/gis/raster/contour.py on lines 98..98

              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

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

                      tiled_input[i * rows:(i + 1) * rows, 0:cols] = \
              Severity: Minor
              Found in safe/gis/raster/contour.py and 1 other location - About 40 mins to fix
              safe/gis/raster/contour.py on lines 90..90

              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

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

                          np.fliplr(tiled_input[i * rows:(i + 1) * rows, 0:cols])
              Severity: Minor
              Found in safe/gis/raster/contour.py and 1 other location - About 40 mins to fix
              safe/gis/raster/contour.py on lines 89..89

              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

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

                      tiled_input[0:rows, i * cols:(i + 1) * cols] = \
              Severity: Minor
              Found in safe/gis/raster/contour.py and 1 other location - About 40 mins to fix
              safe/gis/raster/contour.py on lines 99..99

              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

              Ambiguous variable name 'l'
              Open

                                  for l in range(weights.shape[1]):  # NOQA
              Severity: Minor
              Found in safe/gis/raster/contour.py by pep8

              Never use the characters 'l', 'O', or 'I' as variable names.

              In some fonts, these characters are indistinguishable from the
              numerals one and zero. When tempted to use 'l', use 'L' instead.
              
              Okay: L = 0
              Okay: o = 123
              Okay: i = 42
              E741: l = 0
              E741: O = 123
              E741: I = 42
              
              Variables can be bound in several other contexts, including class
              and function definitions, 'global' and 'nonlocal' statements,
              exception handlers, and 'with' and 'for' statements.
              In addition, we have a special handling for function parameters.
              
              Okay: except AttributeError as o:
              Okay: with lock as L:
              Okay: foo(l=12)
              Okay: for a in foo(l=12):
              E741: except AttributeError as O:
              E741: with lock as l:
              E741: global I
              E741: nonlocal l
              E741: def foo(l):
              E741: def foo(l=12):
              E741: l = foo(l=12)
              E741: for l in range(10):
              E742: class I(object):
              E743: def l(x):

              There are no issues that match your filters.

              Category
              Status