inasafe/inasafe

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

Summary

Maintainability
C
7 hrs
Test Coverage

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

def analysis_summary(aggregate_hazard, analysis):
    """Compute the summary from the aggregate hazard to analysis.

    Source layer :
    | haz_id | haz_class | aggr_id | aggr_name | total_feature |
Severity: Minor
Found in safe/gis/vector/summary_3_analysis.py - About 1 hr to fix

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

        if qgis_version() >= 21600:
            analysis.setName(analysis.keywords['title'])
        else:
            analysis.setLayerName(analysis.keywords['title'])
    Severity: Major
    Found in safe/gis/vector/summary_3_analysis.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_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

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

                if (val == ''
                        or val is None
                        or (hasattr(val, 'isNull')
                            and val.isNull())):
                    val = 'NULL'
    Severity: Major
    Found in safe/gis/vector/summary_3_analysis.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_4_exposure_summary_table.py on lines 147..150

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

            if (hazard_value == ''
                    or hazard_value is None
                    or (hasattr(hazard_value, 'isNull')
                        and hazard_value.isNull())):
                hazard_value = 'NULL'
    Severity: Major
    Found in safe/gis/vector/summary_3_analysis.py and 2 other locations - About 1 hr to fix
    safe/gis/vector/summary_3_analysis.py on lines 184..188
    safe/gis/vector/summary_4_exposure_summary_table.py on lines 147..150

    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

    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_3_analysis.py and 1 other location - About 1 hr to fix
    safe/gis/vector/summary_1_aggregate_hazard.py on lines 156..160

    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

                analysis.changeAttributeValue(
                    area.id(), shift + len(unique_hazard) + 5 + i, value)
    Severity: Minor
    Found in safe/gis/vector/summary_3_analysis.py and 1 other location - About 55 mins to fix
    safe/gis/vector/summary_1_aggregate_hazard.py on lines 210..211

    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

    There are no issues that match your filters.

    Category
    Status