inasafe/inasafe

View on GitHub
safe/gis/vector/summary_4_exposure_summary_table.py

Summary

Maintainability
C
1 day
Test Coverage

Function exposure_summary_table has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def exposure_summary_table(
        aggregate_hazard, exposure_summary=None, callback=None):
    """Compute the summary from the aggregate hazard to analysis.

    Source layer :
Severity: Minor
Found in safe/gis/vector/summary_4_exposure_summary_table.py - About 1 hr to fix

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

        if not summarization_dicts:
            # For each absolute values
            for absolute_field in list(absolute_values.keys()):
                field_definition = definition(absolute_values[absolute_field][1])
                field = create_field_from_definition(field_definition)
    Severity: Major
    Found in safe/gis/vector/summary_4_exposure_summary_table.py and 1 other location - About 5 hrs to fix
    safe/gis/vector/summary_tools.py on lines 108..114

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

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

        if qgis_version() >= 21800:
            tabular.setName(tabular.keywords['title'])
        else:
            tabular.setLayerName(tabular.keywords['title'])
    Severity: Major
    Found in safe/gis/vector/summary_4_exposure_summary_table.py and 6 other locations - About 1 hr to fix
    safe/gis/vector/summary_1_aggregate_hazard.py on lines 217..220
    safe/gis/vector/summary_2_aggregation.py on lines 161..164
    safe/gis/vector/summary_3_analysis.py on lines 256..259
    safe/gis/vector/summary_5_multi_exposure.py on lines 173..176
    safe/gis/vector/summary_5_multi_exposure.py on lines 287..290
    safe/impact_function/create_extra_layers.py on lines 153..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 47.

    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 (hazard_class == '' or hazard_class is None
                    or (hasattr(hazard_class, 'isNull')
                        and hazard_class.isNull())):
                hazard_class = 'NULL'
    Severity: Major
    Found in safe/gis/vector/summary_4_exposure_summary_table.py and 2 other locations - About 1 hr to fix
    safe/gis/vector/summary_3_analysis.py on lines 114..118
    safe/gis/vector/summary_3_analysis.py on lines 184..188

    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

    There are no issues that match your filters.

    Category
    Status