inasafe/inasafe

View on GitHub
safe/report/extractors/general_report.py

Summary

Maintainability
D
2 days
Test Coverage

File general_report.py has 408 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8
"""Module used to extract context for general summary."""
from safe.definitions.exposure import exposure_population
from safe.definitions.fields import (
    hazard_count_field,
Severity: Minor
Found in safe/report/extractors/general_report.py - About 5 hrs to fix

    Function multi_exposure_general_report_extractor has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def multi_exposure_general_report_extractor(impact_report, component_metadata):
        """Extracting general analysis result from the impact layer.
    
        :param impact_report: the impact report that acts as a proxy to fetch
            all the data that extractor needed
    Severity: Minor
    Found in safe/report/extractors/general_report.py - About 1 hr to fix

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

      def general_report_extractor(impact_report, component_metadata):
          """Extracting general analysis result from the impact layer.
      
          :param impact_report: the impact report that acts as a proxy to fetch
              all the data that extractor needed
      Severity: Minor
      Found in safe/report/extractors/general_report.py - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                            if exposure_stats['exposure'] not in exposures:
                                continue
                            classification_result = exposure_stats[
        Severity: Major
        Found in safe/report/extractors/general_report.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if field == fatalities_field:
                                  # For fatalities field, we show a range of number
                                  # instead
                                  row_value = fatalities_range(
                                      analysis_feature[field_index])
          Severity: Major
          Found in safe/report/extractors/general_report.py - About 45 mins to fix

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

                            try:
                                # retrieve dynamic field name from analysis_fields keywords
                                # will cause key error if no hazard count for that
                                # particular class
                                field_name = analysis_inasafe_fields[field_key_name]
            Severity: Major
            Found in safe/report/extractors/general_report.py and 1 other location - About 1 hr to fix
            safe/report/extractors/analysis_detail.py on lines 371..378

            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 field == fatalities_field:
                                    # For fatalities field, we show a range of number
                                    # instead
                                    row_value = fatalities_range(
                                        analysis_feature[field_index])
            Severity: Major
            Found in safe/report/extractors/general_report.py and 1 other location - About 1 hr to fix
            safe/report/extractors/general_report.py on lines 150..156

            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

                        if field == fatalities_field:
                            # For fatalities field, we show a range of number
                            # instead
                            row_value = fatalities_range(analysis_feature[field_index])
                        else:
            Severity: Major
            Found in safe/report/extractors/general_report.py and 1 other location - About 1 hr to fix
            safe/report/extractors/general_report.py on lines 343..350

            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 exposure_stats in exposures_stats:
                        reported_fields_result = exposure_stats['reported_fields_result']
                        value = reported_fields_result[field['key']]
                        values.append(value)
            Severity: Major
            Found in safe/report/extractors/general_report.py and 1 other location - About 1 hr to fix
            safe/report/extractors/general_report.py on lines 382..385

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

            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 exposure_stats in exposures_stats:
                            classification_result = exposure_stats['classification_result']
                            value = classification_result[hazard_class['key']]
                            values.append(value)
            Severity: Major
            Found in safe/report/extractors/general_report.py and 1 other location - About 1 hr to fix
            safe/report/extractors/general_report.py on lines 474..477

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

            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