inasafe/inasafe

View on GitHub
safe/gui/tools/shake_grid/shake_grid.py

Summary

Maintainability
F
4 days
Test Coverage

File shake_grid.py has 833 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8
"""A converter for USGS shakemap grid.xml files."""


import codecs
Severity: Major
Found in safe/gui/tools/shake_grid/shake_grid.py - About 2 days to fix

    Function mmi_to_contours has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def mmi_to_contours(self, force_flag=True, algorithm=USE_ASCII):
            """Extract contours from the event's tif file.
    
            Contours are extracted at a 0.5 MMI interval. The resulting file will
            be saved in the extract directory. In the easiest use case you can
    Severity: Minor
    Found in safe/gui/tools/shake_grid/shake_grid.py - About 1 hr to fix

      Function __init__ has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(
                  self,
                  title,
                  source,
                  grid_xml_path,
      Severity: Minor
      Found in safe/gui/tools/shake_grid/shake_grid.py - About 1 hr to fix

        Function convert_mmi_data has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def convert_mmi_data(
        Severity: Major
        Found in safe/gui/tools/shake_grid/shake_grid.py - About 1 hr to fix

          Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Major
          Found in safe/gui/tools/shake_grid/shake_grid.py - About 1 hr to fix

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

                    if self.algorithm_name:
                        layer_path = os.path.join(
                            self.output_dir, '%s-%s.tif' % (
                                self.output_basename, algorithm))
                    else:
            Severity: Major
            Found in safe/gui/tools/shake_grid/shake_grid.py and 2 other locations - About 2 hrs to fix
            safe/gui/tools/shake_grid/shake_grid.py on lines 578..584
            safe/gui/tools/shake_grid/shake_grid.py on lines 654..660

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

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

                    if self.algorithm_name:
                        qml_path = os.path.join(
                            self.output_dir, '%s-%s.qml' % (
                                self.output_basename, algorithm))
                    else:
            Severity: Major
            Found in safe/gui/tools/shake_grid/shake_grid.py and 2 other locations - About 2 hrs to fix
            safe/gui/tools/shake_grid/shake_grid.py on lines 578..584
            safe/gui/tools/shake_grid/shake_grid.py on lines 949..955

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

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

                    if self.algorithm_name:
                        tif_path = os.path.join(
                            self.output_dir, '%s-%s.tif' % (
                                self.output_basename, algorithm))
                    else:
            Severity: Major
            Found in safe/gui/tools/shake_grid/shake_grid.py and 2 other locations - About 2 hrs to fix
            safe/gui/tools/shake_grid/shake_grid.py on lines 654..660
            safe/gui/tools/shake_grid/shake_grid.py on lines 949..955

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

            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(
                            tif_dataset.GetRasterBand(band),
                            contour_interval,
                            contour_base,
            Severity: Major
            Found in safe/gui/tools/shake_grid/shake_grid.py and 1 other location - About 2 hrs to fix
            safe/gis/raster/contour.py on lines 397..410

            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

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

                            ncols = len(np.where(np.array(lon_list) == lon_list[0])[0])
            Severity: Major
            Found in safe/gui/tools/shake_grid/shake_grid.py and 3 other locations - About 1 hr to fix
            safe/gui/tools/shake_grid/shake_grid.py on lines 353..353
            safe/gui/tools/shake_grid/shake_grid.py on lines 354..354
            safe/gui/tools/shake_grid/shake_grid.py on lines 369..369

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

            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

                            ncols = len(np.where(np.array(lon_list) == lon_list[0])[0])
            Severity: Major
            Found in safe/gui/tools/shake_grid/shake_grid.py and 3 other locations - About 1 hr to fix
            safe/gui/tools/shake_grid/shake_grid.py on lines 354..354
            safe/gui/tools/shake_grid/shake_grid.py on lines 368..368
            safe/gui/tools/shake_grid/shake_grid.py on lines 369..369

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

            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

                            nrows = len(np.where(np.array(lat_list) == lat_list[0])[0])
            Severity: Major
            Found in safe/gui/tools/shake_grid/shake_grid.py and 3 other locations - About 1 hr to fix
            safe/gui/tools/shake_grid/shake_grid.py on lines 353..353
            safe/gui/tools/shake_grid/shake_grid.py on lines 368..368
            safe/gui/tools/shake_grid/shake_grid.py on lines 369..369

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

            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

                            nrows = len(np.where(np.array(lat_list) == lat_list[0])[0])
            Severity: Major
            Found in safe/gui/tools/shake_grid/shake_grid.py and 3 other locations - About 1 hr to fix
            safe/gui/tools/shake_grid/shake_grid.py on lines 353..353
            safe/gui/tools/shake_grid/shake_grid.py on lines 354..354
            safe/gui/tools/shake_grid/shake_grid.py on lines 368..368

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

            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