inasafe/inasafe

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

Summary

Maintainability
B
6 hrs
Test Coverage

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

def aggregate_hazard_summary(impact, aggregate_hazard):
    """Compute the summary from the source layer to the aggregate_hazard layer.

    Source layer :
    |exp_id|exp_class|haz_id|haz_class|aggr_id|aggr_name|affected|extra*|
Severity: Minor
Found in safe/gis/vector/summary_1_aggregate_hazard.py - About 1 hr to fix

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

        if qgis_version() >= 21800:
            aggregate_hazard.setName(aggregate_hazard.keywords['title'])
        else:
            aggregate_hazard.setLayerName(aggregate_hazard.keywords['title'])
    Severity: Major
    Found in safe/gis/vector/summary_1_aggregate_hazard.py and 6 other locations - About 1 hr to fix
    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_4_exposure_summary_table.py on lines 267..270
    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

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

                if (value == ''
                        or value is None
                        or (hasattr(value, 'isNull')
                            and value.isNull())):
                    value = 0
    Severity: Major
    Found in safe/gis/vector/summary_1_aggregate_hazard.py and 1 other location - About 1 hr to fix
    safe/gis/vector/summary_3_analysis.py on lines 127..131

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

                aggregate_hazard.changeAttributeValue(
                    area.id(), shift + len(unique_exposure) + 2 + i, value)
    Severity: Minor
    Found in safe/gis/vector/summary_1_aggregate_hazard.py and 1 other location - About 55 mins to fix
    safe/gis/vector/summary_3_analysis.py on lines 230..231

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

    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 (hazard_value is None
                    or hazard_value == ''
                    or (hasattr(hazard_value, 'isNull')
                        and hazard_value.isNull())):
    Severity: Major
    Found in safe/gis/vector/summary_1_aggregate_hazard.py and 3 other locations - About 35 mins to fix
    safe/gis/vector/default_values.py on lines 101..102
    safe/gis/vector/summary_1_aggregate_hazard.py on lines 140..143
    safe/gis/vector/summary_2_aggregation.py on lines 111..113

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

    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 (exposure_value is None
                    or exposure_value == ''
                    or (hasattr(exposure_value, 'isNull')
                        and exposure_value.isNull())):
    Severity: Major
    Found in safe/gis/vector/summary_1_aggregate_hazard.py and 3 other locations - About 35 mins to fix
    safe/gis/vector/default_values.py on lines 101..102
    safe/gis/vector/summary_1_aggregate_hazard.py on lines 134..137
    safe/gis/vector/summary_2_aggregation.py on lines 111..113

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

    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