inasafe/inasafe

View on GitHub
safe/impact_function/multi_exposure_wrapper.py

Summary

Maintainability
F
1 wk
Test Coverage

File multi_exposure_wrapper.py has 1192 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8

"""
Multi-exposure wrapper.

Severity: Major
Found in safe/impact_function/multi_exposure_wrapper.py - About 3 days to fix

    MultiExposureImpactFunction has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MultiExposureImpactFunction():
    
        """Multi-exposure wrapper.
    
        .. versionadded:: 4.3
    Severity: Minor
    Found in safe/impact_function/multi_exposure_wrapper.py - About 4 hrs to fix

      Function run has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def run(self):
              """Run the whole impact function.
      
              :return: A tuple with the status of the IF and an error message if
                  needed. If the status is FAILED, and if the error is related to a
      Severity: Major
      Found in safe/impact_function/multi_exposure_wrapper.py - About 2 hrs to fix

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

            def __init__(self):
                """Constructor."""
                # Input layers
                self._hazard = None
                self._aggregation = None
        Severity: Minor
        Found in safe/impact_function/multi_exposure_wrapper.py - About 1 hr to fix

          Function load_from_output_metadata has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def load_from_output_metadata(output_metadata):
                  """Set Impact Function based on an output of an analysis's metadata.
          
                  If possible, we will try to use layers already in the legend and to not
                  recreating new ones. We will keep the style for instance.
          Severity: Minor
          Found in safe/impact_function/multi_exposure_wrapper.py - About 1 hr to fix

            Function prepare has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def prepare(self):
                    """Method to check if the impact function can be run.
            
                    :return: A tuple with the status of the IF and an error message if
                        needed.
            Severity: Minor
            Found in safe/impact_function/multi_exposure_wrapper.py - About 1 hr to fix

              Function generate_report has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def generate_report(
              Severity: Major
              Found in safe/impact_function/multi_exposure_wrapper.py - About 50 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        for sub_impact_function in self.impact_functions:
                                            # Iterate over each sub impact function used in the
                                            # multi exposure analysis.
                                            if sub_impact_function.name == layer_definition[2]:
                                                for layer in sub_impact_function.outputs:
                Severity: Major
                Found in safe/impact_function/multi_exposure_wrapper.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for tree_layer in tree_layers:
                                              layer_purpose = KeywordIO.read_keywords(
                                                  tree_layer.layer(), 'layer_purpose')
                                              if layer_purpose == (
                                                      layer_purpose_exposure_summary['key']):
                  Severity: Major
                  Found in safe/impact_function/multi_exposure_wrapper.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if not status:
                                                    return status, message
                                        elif len(property_a) and \
                    Severity: Major
                    Found in safe/impact_function/multi_exposure_wrapper.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for layer in self.outputs:
                                                  if layer.keywords['layer_purpose'] == (
                                                          layer_definition[1]):
                                                      extra_layer = layer
                                                      break
                      Severity: Major
                      Found in safe/impact_function/multi_exposure_wrapper.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if not impact_layer:
                                                    for tree_layer in tree_layers:
                                                        layer_purpose = KeywordIO.read_keywords(
                                                            tree_layer.layer(), 'layer_purpose')
                                                        if layer_purpose == (
                        Severity: Major
                        Found in safe/impact_function/multi_exposure_wrapper.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if layer_id == impact_function.analysis_impacted.id():
                                                      population_analysis_summary = layer
                                              # FIXME: add_layer_to_canvas() requires a layer AND a name
                                              if not population_analysis_summary:
                          Severity: Major
                          Found in safe/impact_function/multi_exposure_wrapper.py - About 45 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                            return code, message
                            Severity: Major
                            Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                                      return False, message
                              Severity: Major
                              Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return True, ''
                                Severity: Major
                                Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                          return False, message
                                  Severity: Major
                                  Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                    return False, message
                                    Severity: Major
                                    Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                      return False, message
                                      Severity: Major
                                      Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                            return False, message
                                        Severity: Major
                                        Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                          return PREPARE_FAILED_BAD_INPUT, message
                                          Severity: Major
                                          Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                                            return status, message
                                            Severity: Major
                                            Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                              return PREPARE_FAILED_BAD_INPUT, message
                                              Severity: Major
                                              Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return PREPARE_SUCCESS, None
                                                Severity: Major
                                                Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                                  return status, message
                                                  Severity: Major
                                                  Found in safe/impact_function/multi_exposure_wrapper.py - About 30 mins to fix

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

                                                                if isinstance(layer_a, QgsVectorLayer):
                                                                    fields_a = [f.name() for f in layer_a.fields()]
                                                                    fields_b = [f.name() for f in layer_b.fields()]
                                                                    if fields_a != fields_b:
                                                                        message = (
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 7 hrs to fix
                                                    safe/impact_function/impact_function.py on lines 394..407

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

                                                    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

                                                                try:
                                                                    property_a = getattr(self, if_property)
                                                                    property_b = getattr(other, if_property)
                                                                    if not isinstance(property_a, type(property_b)):
                                                                        message = (
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 5 hrs to fix
                                                    safe/impact_function/impact_function.py on lines 380..448

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

                                                    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

                                                                if default_user_directory:
                                                                    path = join(default_user_directory, self._unique_name)
                                                                    if not exists(path):
                                                                        makedirs(path)
                                                                    self._datastore = Folder(path)
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 3 hrs to fix
                                                    safe/impact_function/impact_function.py on lines 1604..1610

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

                                                    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

                                                        @property
                                                        def duration(self):
                                                            """The duration of running the impact function in seconds.
                                                    
                                                            Return 0 if the start or end datetime is None.
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 2 hrs to fix
                                                    safe/impact_function/impact_function.py on lines 853..864

                                                    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

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

                                                                    elif isinstance(property_a, QgsGeometry):
                                                                        if not property_a.equals(property_b):
                                                                            string_a = property_a.asWkt()
                                                                            string_b = property_b.asWkt()
                                                                            message = (
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 2 hrs to fix
                                                    safe/impact_function/impact_function.py on lines 408..415

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

                                                    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

                                                        @crs.setter
                                                        def crs(self, crs):
                                                            """Setter for extent_crs property.
                                                    
                                                            :param crs: The coordinate reference system for the analysis boundary.
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 2 other locations - About 2 hrs to fix
                                                    safe/impact_function/impact_function.py on lines 747..760
                                                    safe/impact_function/impact_function.py on lines 774..785

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

                                                    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

                                                                    elif isinstance(property_a, DataStore):
                                                                        if property_a.uri_path != property_b.uri_path:
                                                                            string_a = property_a.uri_path
                                                                            string_b = property_b.uri_path
                                                                            message = (
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 1 hr to fix
                                                    safe/impact_function/impact_function.py on lines 416..423

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

                                                    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

                                                                            if not impact_layer:
                                                                                for tree_layer in tree_layers:
                                                                                    layer_purpose = KeywordIO.read_keywords(
                                                                                        tree_layer.layer(), 'layer_purpose')
                                                                                    if layer_purpose == (
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 1 hr to fix
                                                    safe/impact_function/multi_exposure_wrapper.py on lines 1262..1268

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

                                                    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

                                                                            for tree_layer in tree_layers:
                                                                                layer_purpose = KeywordIO.read_keywords(
                                                                                    tree_layer.layer(), 'layer_purpose')
                                                                                if layer_purpose == (
                                                                                        layer_purpose_exposure_summary['key']):
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 1 hr to fix
                                                    safe/impact_function/multi_exposure_wrapper.py on lines 1271..1279

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

                                                    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

                                                                    if not isinstance(property_a, type(property_b)):
                                                                        message = (
                                                                            'Different type of property %s.\nA: %s\nB: %s' % (
                                                                                if_property, type(property_a), type(property_b)))
                                                                        return False, message
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 1 hr to fix
                                                    safe/impact_function/impact_function.py on lines 383..387

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

                                                    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

                                                        @datastore.setter
                                                        def datastore(self, datastore):
                                                            """Setter for the datastore.
                                                    
                                                            :param datastore: The datastore.
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 1 hr to fix
                                                    safe/impact_function/impact_function.py on lines 805..815

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

                                                    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

                                                                    elif (isinstance(property_a, tuple)
                                                                          or isinstance(property_a, list)):
                                                                        if len(property_a) == len(property_b) == 0:
                                                                            continue
                                                                        elif len(property_a) and \
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 1 hr to fix
                                                    safe/impact_function/impact_function.py on lines 416..431

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

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

                                                            if self.aggregation:
                                                                status, message = check_input_layer(
                                                                    self.aggregation, 'aggregation')
                                                                if status != PREPARE_SUCCESS:
                                                                    return status, message
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 4 other locations - About 1 hr to fix
                                                    safe/impact_function/impact_function.py on lines 1009..1016
                                                    safe/impact_function/impact_function.py on lines 1022..1029
                                                    safe/impact_function/impact_function.py on lines 1074..1082
                                                    safe/impact_function/impact_function.py on lines 1438..1444

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

                                                    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

                                                                if byteify(layer_a.keywords) != byteify(
                                                                        layer_b.keywords):
                                                                    message = (
                                                                        'Keyword Layer is not equal is %s' % if_property)
                                                                    return False, message
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 1 hr to fix
                                                    safe/impact_function/impact_function.py on lines 389..393

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

                                                            if len(self._exposures) < 2:  # 2 layers minimum.
                                                                message = generate_input_error_message(
                                                                    tr('Not enough exposure layer'),
                                                                    m.Paragraph(tr('You need to provide at least two exposures.')))
                                                                self._is_ready = False
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 1 hr to fix
                                                    safe/impact_function/multi_exposure_wrapper.py on lines 760..765

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

                                                    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

                                                                if exposure.keywords['exposure'] in existing_exposure:
                                                                    message = generate_input_error_message(
                                                                        tr('Same exposure'),
                                                                        m.Paragraph(tr('Not the same exposure')))
                                                                    self._is_ready = False
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 1 other location - About 1 hr to fix
                                                    safe/impact_function/multi_exposure_wrapper.py on lines 747..752

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

                                                    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

                                                                if self._crs:
                                                                    message = generate_input_error_message(
                                                                        tr('Error with the requested CRS'),
                                                                        m.Paragraph(tr(
                                                                            'Requested CRS must be null when an '
                                                    Severity: Major
                                                    Found in safe/impact_function/multi_exposure_wrapper.py and 3 other locations - About 50 mins to fix
                                                    safe/impact_function/impact_function.py on lines 1036..1043
                                                    safe/impact_function/impact_function.py on lines 1045..1052
                                                    safe/impact_function/impact_function.py on lines 1054..1061

                                                    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

                                                    There are no issues that match your filters.

                                                    Category
                                                    Status