inasafe/inasafe

View on GitHub
safe/processors/population_post_processors.py

Summary

Maintainability
D
1 day
Test Coverage

File population_post_processors.py has 811 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8

"""Postprocessors about population and demographics."""

from collections import OrderedDict
Severity: Major
Found in safe/processors/population_post_processors.py - About 1 day to fix

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

    post_processor_female = {
        'key': 'post_processor_female',
        'name': tr('Female Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced females.'
    Severity: Major
    Found in safe/processors/population_post_processors.py and 1 other location - About 1 day to fix
    safe/processors/population_post_processors.py on lines 383..421

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

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

    post_processor_male = {
        'key': 'post_processor_male',
        'name': tr('Male Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced males.'
    Severity: Major
    Found in safe/processors/population_post_processors.py and 1 other location - About 1 day to fix
    safe/processors/population_post_processors.py on lines 425..463

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

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

    post_processor_elderly = {
        'key': 'post_processor_elderly',
        'name': tr('Elderly Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced elderly '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 254..293
    safe/processors/population_post_processors.py on lines 298..336
    safe/processors/population_post_processors.py on lines 340..378
    safe/processors/population_post_processors.py on lines 500..537
    safe/processors/population_post_processors.py on lines 541..578
    safe/processors/population_post_processors.py on lines 582..619
    safe/processors/population_post_processors.py on lines 623..660
    safe/processors/population_post_processors.py on lines 705..742
    safe/processors/population_post_processors.py on lines 746..783
    safe/processors/population_post_processors.py on lines 787..825

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

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

    post_processor_child = {
        'key': 'post_processor_child',
        'name': tr('Child Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced child. '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 254..293
    safe/processors/population_post_processors.py on lines 298..336
    safe/processors/population_post_processors.py on lines 340..378
    safe/processors/population_post_processors.py on lines 500..537
    safe/processors/population_post_processors.py on lines 582..619
    safe/processors/population_post_processors.py on lines 623..660
    safe/processors/population_post_processors.py on lines 664..701
    safe/processors/population_post_processors.py on lines 705..742
    safe/processors/population_post_processors.py on lines 746..783
    safe/processors/population_post_processors.py on lines 787..825

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

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

    post_processor_adult = {
        'key': 'post_processor_adult',
        'name': tr('Adult Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced adults. '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 254..293
    safe/processors/population_post_processors.py on lines 298..336
    safe/processors/population_post_processors.py on lines 340..378
    safe/processors/population_post_processors.py on lines 500..537
    safe/processors/population_post_processors.py on lines 541..578
    safe/processors/population_post_processors.py on lines 582..619
    safe/processors/population_post_processors.py on lines 664..701
    safe/processors/population_post_processors.py on lines 705..742
    safe/processors/population_post_processors.py on lines 746..783
    safe/processors/population_post_processors.py on lines 787..825

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

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

    post_processor_under_5 = {
        'key': 'post_processor_under_5',
        'name': tr('Under 5 Years Old Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced under 5 '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 254..293
    safe/processors/population_post_processors.py on lines 298..336
    safe/processors/population_post_processors.py on lines 340..378
    safe/processors/population_post_processors.py on lines 500..537
    safe/processors/population_post_processors.py on lines 541..578
    safe/processors/population_post_processors.py on lines 582..619
    safe/processors/population_post_processors.py on lines 623..660
    safe/processors/population_post_processors.py on lines 664..701
    safe/processors/population_post_processors.py on lines 746..783
    safe/processors/population_post_processors.py on lines 787..825

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

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

    post_processor_lactating = {
        'key': 'post_processor_lactating',
        'name': tr('Lactating Women Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced lactating '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 254..293
    safe/processors/population_post_processors.py on lines 298..336
    safe/processors/population_post_processors.py on lines 500..537
    safe/processors/population_post_processors.py on lines 541..578
    safe/processors/population_post_processors.py on lines 582..619
    safe/processors/population_post_processors.py on lines 623..660
    safe/processors/population_post_processors.py on lines 664..701
    safe/processors/population_post_processors.py on lines 705..742
    safe/processors/population_post_processors.py on lines 746..783
    safe/processors/population_post_processors.py on lines 787..825

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

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

    post_processor_youth = {
        'key': 'post_processor_youth',
        'name': tr('Youth Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced youth. '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 254..293
    safe/processors/population_post_processors.py on lines 298..336
    safe/processors/population_post_processors.py on lines 340..378
    safe/processors/population_post_processors.py on lines 500..537
    safe/processors/population_post_processors.py on lines 541..578
    safe/processors/population_post_processors.py on lines 623..660
    safe/processors/population_post_processors.py on lines 664..701
    safe/processors/population_post_processors.py on lines 705..742
    safe/processors/population_post_processors.py on lines 746..783
    safe/processors/population_post_processors.py on lines 787..825

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

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

    post_processor_child_bearing_age = {
        'key': 'post_processor_child_bearing_age',
        'name': tr('Child Bearing Age Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced child bearing '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 298..336
    safe/processors/population_post_processors.py on lines 340..378
    safe/processors/population_post_processors.py on lines 500..537
    safe/processors/population_post_processors.py on lines 541..578
    safe/processors/population_post_processors.py on lines 582..619
    safe/processors/population_post_processors.py on lines 623..660
    safe/processors/population_post_processors.py on lines 664..701
    safe/processors/population_post_processors.py on lines 705..742
    safe/processors/population_post_processors.py on lines 746..783
    safe/processors/population_post_processors.py on lines 787..825

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

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

    post_processor_over_60 = {
        'key': 'post_processor_over_60',
        'name': tr('Over 60 Years Old Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced over 60 '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 254..293
    safe/processors/population_post_processors.py on lines 298..336
    safe/processors/population_post_processors.py on lines 340..378
    safe/processors/population_post_processors.py on lines 500..537
    safe/processors/population_post_processors.py on lines 541..578
    safe/processors/population_post_processors.py on lines 582..619
    safe/processors/population_post_processors.py on lines 623..660
    safe/processors/population_post_processors.py on lines 664..701
    safe/processors/population_post_processors.py on lines 705..742
    safe/processors/population_post_processors.py on lines 787..825

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

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

    post_processor_pregnant = {
        'key': 'post_processor_pregnant',
        'name': tr('Pregnant Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced pregnant '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 254..293
    safe/processors/population_post_processors.py on lines 340..378
    safe/processors/population_post_processors.py on lines 500..537
    safe/processors/population_post_processors.py on lines 541..578
    safe/processors/population_post_processors.py on lines 582..619
    safe/processors/population_post_processors.py on lines 623..660
    safe/processors/population_post_processors.py on lines 664..701
    safe/processors/population_post_processors.py on lines 705..742
    safe/processors/population_post_processors.py on lines 746..783
    safe/processors/population_post_processors.py on lines 787..825

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

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

    post_processor_infant = {
        'key': 'post_processor_infant',
        'name': tr('Infant Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced infant. '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 254..293
    safe/processors/population_post_processors.py on lines 298..336
    safe/processors/population_post_processors.py on lines 340..378
    safe/processors/population_post_processors.py on lines 541..578
    safe/processors/population_post_processors.py on lines 582..619
    safe/processors/population_post_processors.py on lines 623..660
    safe/processors/population_post_processors.py on lines 664..701
    safe/processors/population_post_processors.py on lines 705..742
    safe/processors/population_post_processors.py on lines 746..783
    safe/processors/population_post_processors.py on lines 787..825

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

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

    post_processor_disability_vulnerability = {
        'key': 'post_processor_disability_vulnerability',
        'name': tr('Disability Vulnerability Post Processor'),
        'description': tr(
            'A post processor to calculate the number of displaced people '
    Severity: Major
    Found in safe/processors/population_post_processors.py and 10 other locations - About 1 day to fix
    safe/processors/population_post_processors.py on lines 254..293
    safe/processors/population_post_processors.py on lines 298..336
    safe/processors/population_post_processors.py on lines 340..378
    safe/processors/population_post_processors.py on lines 500..537
    safe/processors/population_post_processors.py on lines 541..578
    safe/processors/population_post_processors.py on lines 582..619
    safe/processors/population_post_processors.py on lines 623..660
    safe/processors/population_post_processors.py on lines 664..701
    safe/processors/population_post_processors.py on lines 705..742
    safe/processors/population_post_processors.py on lines 746..783

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

    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