inasafe/inasafe

View on GitHub
safe/report/expressions/infographic.py

Summary

Maintainability
F
4 days
Test Coverage

File infographic.py has 264 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8

"""QGIS Expressions which are available in the QGIS GUI interface."""

from qgis.core import qgsfunction
Severity: Minor
Found in safe/report/expressions/infographic.py - About 2 hrs to fix

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

    @qgsfunction(
        args='auto', group=group, usesGeometry=False, referencedColumns=[],
        help_text=help_message.to_html(), helpText=help_message.to_html())
    def people_section_header_element(feature, parent):
        """Retrieve people section header string from definitions."""
    Severity: Major
    Found in safe/report/expressions/infographic.py and 18 other locations - About 3 hrs to fix
    safe/report/expressions/infographic.py on lines 174..181
    safe/report/expressions/infographic.py on lines 191..198
    safe/report/expressions/infographic.py on lines 225..232
    safe/report/expressions/infographic.py on lines 260..267
    safe/report/expressions/infographic.py on lines 278..285
    safe/report/expressions/infographic.py on lines 296..303
    safe/report/expressions/infographic.py on lines 314..323
    safe/report/expressions/map_report.py on lines 82..89
    safe/report/expressions/map_report.py on lines 285..292
    safe/report/expressions/map_report.py on lines 320..327
    safe/report/expressions/map_report.py on lines 338..345
    safe/report/expressions/map_report.py on lines 356..363
    safe/report/expressions/map_report.py on lines 392..399
    safe/report/expressions/map_report.py on lines 410..417
    safe/report/expressions/map_report.py on lines 428..435
    safe/report/expressions/map_report.py on lines 446..453
    safe/report/expressions/map_report.py on lines 488..495
    safe/report/expressions/map_report.py on lines 506..513

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

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

    @qgsfunction(
        args='auto', group=group, usesGeometry=False, referencedColumns=[],
        help_text=help_message.to_html(), helpText=help_message.to_html())
    def vulnerability_section_header_element(feature, parent):
        """Retrieve vulnerability section header string from definitions."""
    Severity: Major
    Found in safe/report/expressions/infographic.py and 18 other locations - About 3 hrs to fix
    safe/report/expressions/infographic.py on lines 174..181
    safe/report/expressions/infographic.py on lines 191..198
    safe/report/expressions/infographic.py on lines 208..215
    safe/report/expressions/infographic.py on lines 225..232
    safe/report/expressions/infographic.py on lines 278..285
    safe/report/expressions/infographic.py on lines 296..303
    safe/report/expressions/infographic.py on lines 314..323
    safe/report/expressions/map_report.py on lines 82..89
    safe/report/expressions/map_report.py on lines 285..292
    safe/report/expressions/map_report.py on lines 320..327
    safe/report/expressions/map_report.py on lines 338..345
    safe/report/expressions/map_report.py on lines 356..363
    safe/report/expressions/map_report.py on lines 392..399
    safe/report/expressions/map_report.py on lines 410..417
    safe/report/expressions/map_report.py on lines 428..435
    safe/report/expressions/map_report.py on lines 446..453
    safe/report/expressions/map_report.py on lines 488..495
    safe/report/expressions/map_report.py on lines 506..513

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

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

    @qgsfunction(
        args='auto', group=group, usesGeometry=False, referencedColumns=[],
        help_text=help_message.to_html(), helpText=help_message.to_html())
    def female_vulnerability_section_header_element(feature, parent):
        """Retrieve female vulnerability section header string from definitions."""
    Severity: Major
    Found in safe/report/expressions/infographic.py and 18 other locations - About 3 hrs to fix
    safe/report/expressions/infographic.py on lines 174..181
    safe/report/expressions/infographic.py on lines 191..198
    safe/report/expressions/infographic.py on lines 208..215
    safe/report/expressions/infographic.py on lines 225..232
    safe/report/expressions/infographic.py on lines 260..267
    safe/report/expressions/infographic.py on lines 296..303
    safe/report/expressions/infographic.py on lines 314..323
    safe/report/expressions/map_report.py on lines 82..89
    safe/report/expressions/map_report.py on lines 285..292
    safe/report/expressions/map_report.py on lines 320..327
    safe/report/expressions/map_report.py on lines 338..345
    safe/report/expressions/map_report.py on lines 356..363
    safe/report/expressions/map_report.py on lines 392..399
    safe/report/expressions/map_report.py on lines 410..417
    safe/report/expressions/map_report.py on lines 428..435
    safe/report/expressions/map_report.py on lines 446..453
    safe/report/expressions/map_report.py on lines 488..495
    safe/report/expressions/map_report.py on lines 506..513

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

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

    @qgsfunction(
        args='auto', group=group, usesGeometry=False, referencedColumns=[],
        help_text=help_message.to_html(), helpText=help_message.to_html())
    def map_overview_header_element(feature, parent):
        """Retrieve map overview header string from definitions."""
    Severity: Major
    Found in safe/report/expressions/infographic.py and 18 other locations - About 3 hrs to fix
    safe/report/expressions/infographic.py on lines 191..198
    safe/report/expressions/infographic.py on lines 208..215
    safe/report/expressions/infographic.py on lines 225..232
    safe/report/expressions/infographic.py on lines 260..267
    safe/report/expressions/infographic.py on lines 278..285
    safe/report/expressions/infographic.py on lines 296..303
    safe/report/expressions/infographic.py on lines 314..323
    safe/report/expressions/map_report.py on lines 82..89
    safe/report/expressions/map_report.py on lines 285..292
    safe/report/expressions/map_report.py on lines 320..327
    safe/report/expressions/map_report.py on lines 338..345
    safe/report/expressions/map_report.py on lines 356..363
    safe/report/expressions/map_report.py on lines 392..399
    safe/report/expressions/map_report.py on lines 410..417
    safe/report/expressions/map_report.py on lines 428..435
    safe/report/expressions/map_report.py on lines 446..453
    safe/report/expressions/map_report.py on lines 488..495
    safe/report/expressions/map_report.py on lines 506..513

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

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

    @qgsfunction(
        args='auto', group=group, usesGeometry=False, referencedColumns=[],
        help_text=help_message.to_html(), helpText=help_message.to_html())
    def additional_minimum_needs_section_header_element(feature, parent):
        """Retrieve additional minimum needs section header string
    Severity: Major
    Found in safe/report/expressions/infographic.py and 18 other locations - About 3 hrs to fix
    safe/report/expressions/infographic.py on lines 174..181
    safe/report/expressions/infographic.py on lines 191..198
    safe/report/expressions/infographic.py on lines 208..215
    safe/report/expressions/infographic.py on lines 225..232
    safe/report/expressions/infographic.py on lines 260..267
    safe/report/expressions/infographic.py on lines 278..285
    safe/report/expressions/infographic.py on lines 296..303
    safe/report/expressions/map_report.py on lines 82..89
    safe/report/expressions/map_report.py on lines 285..292
    safe/report/expressions/map_report.py on lines 320..327
    safe/report/expressions/map_report.py on lines 338..345
    safe/report/expressions/map_report.py on lines 356..363
    safe/report/expressions/map_report.py on lines 392..399
    safe/report/expressions/map_report.py on lines 410..417
    safe/report/expressions/map_report.py on lines 428..435
    safe/report/expressions/map_report.py on lines 446..453
    safe/report/expressions/map_report.py on lines 488..495
    safe/report/expressions/map_report.py on lines 506..513

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

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

    @qgsfunction(
        args='auto', group=group, usesGeometry=False, referencedColumns=[],
        help_text=help_message.to_html(), helpText=help_message.to_html())
    def minimum_needs_section_header_element(feature, parent):
        """Retrieve minimum needs section header string from definitions."""
    Severity: Major
    Found in safe/report/expressions/infographic.py and 18 other locations - About 3 hrs to fix
    safe/report/expressions/infographic.py on lines 174..181
    safe/report/expressions/infographic.py on lines 191..198
    safe/report/expressions/infographic.py on lines 208..215
    safe/report/expressions/infographic.py on lines 225..232
    safe/report/expressions/infographic.py on lines 260..267
    safe/report/expressions/infographic.py on lines 278..285
    safe/report/expressions/infographic.py on lines 314..323
    safe/report/expressions/map_report.py on lines 82..89
    safe/report/expressions/map_report.py on lines 285..292
    safe/report/expressions/map_report.py on lines 320..327
    safe/report/expressions/map_report.py on lines 338..345
    safe/report/expressions/map_report.py on lines 356..363
    safe/report/expressions/map_report.py on lines 392..399
    safe/report/expressions/map_report.py on lines 410..417
    safe/report/expressions/map_report.py on lines 428..435
    safe/report/expressions/map_report.py on lines 446..453
    safe/report/expressions/map_report.py on lines 488..495
    safe/report/expressions/map_report.py on lines 506..513

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

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

    @qgsfunction(
        args='auto', group=group, usesGeometry=False, referencedColumns=[],
        help_text=help_message.to_html(), helpText=help_message.to_html())
    def age_gender_section_header_element(feature, parent):
        """Retrieve age gender section header string from definitions."""
    Severity: Major
    Found in safe/report/expressions/infographic.py and 18 other locations - About 3 hrs to fix
    safe/report/expressions/infographic.py on lines 174..181
    safe/report/expressions/infographic.py on lines 191..198
    safe/report/expressions/infographic.py on lines 208..215
    safe/report/expressions/infographic.py on lines 260..267
    safe/report/expressions/infographic.py on lines 278..285
    safe/report/expressions/infographic.py on lines 296..303
    safe/report/expressions/infographic.py on lines 314..323
    safe/report/expressions/map_report.py on lines 82..89
    safe/report/expressions/map_report.py on lines 285..292
    safe/report/expressions/map_report.py on lines 320..327
    safe/report/expressions/map_report.py on lines 338..345
    safe/report/expressions/map_report.py on lines 356..363
    safe/report/expressions/map_report.py on lines 392..399
    safe/report/expressions/map_report.py on lines 410..417
    safe/report/expressions/map_report.py on lines 428..435
    safe/report/expressions/map_report.py on lines 446..453
    safe/report/expressions/map_report.py on lines 488..495
    safe/report/expressions/map_report.py on lines 506..513

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

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

    @qgsfunction(
        args='auto', group=group, usesGeometry=False, referencedColumns=[],
        help_text=help_message.to_html(), helpText=help_message.to_html())
    def population_chart_header_element(feature, parent):
        """Retrieve population chart header string from definitions."""
    Severity: Major
    Found in safe/report/expressions/infographic.py and 18 other locations - About 3 hrs to fix
    safe/report/expressions/infographic.py on lines 174..181
    safe/report/expressions/infographic.py on lines 208..215
    safe/report/expressions/infographic.py on lines 225..232
    safe/report/expressions/infographic.py on lines 260..267
    safe/report/expressions/infographic.py on lines 278..285
    safe/report/expressions/infographic.py on lines 296..303
    safe/report/expressions/infographic.py on lines 314..323
    safe/report/expressions/map_report.py on lines 82..89
    safe/report/expressions/map_report.py on lines 285..292
    safe/report/expressions/map_report.py on lines 320..327
    safe/report/expressions/map_report.py on lines 338..345
    safe/report/expressions/map_report.py on lines 356..363
    safe/report/expressions/map_report.py on lines 392..399
    safe/report/expressions/map_report.py on lines 410..417
    safe/report/expressions/map_report.py on lines 428..435
    safe/report/expressions/map_report.py on lines 446..453
    safe/report/expressions/map_report.py on lines 488..495
    safe/report/expressions/map_report.py on lines 506..513

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

    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

    @qgsfunction(
        args='auto', group=group, usesGeometry=False, referencedColumns=[],
        help_text=help_message.to_html(), helpText=help_message.to_html())
    def age_gender_section_notes_element(feature, parent):
        """Retrieve age gender section notes string from definitions."""
    Severity: Major
    Found in safe/report/expressions/infographic.py and 2 other locations - About 3 hrs to fix
    safe/report/expressions/infographic.py on lines 334..341
    safe/report/expressions/map_report.py on lines 374..381

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

    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

    @qgsfunction(
        args='auto', group=group, usesGeometry=False, referencedColumns=[],
        help_text=help_message.to_html(), helpText=help_message.to_html())
    def minimum_needs_section_notes_element(feature, parent):
        """Retrieve minimum needs section notes string from definitions."""
    Severity: Major
    Found in safe/report/expressions/infographic.py and 2 other locations - About 3 hrs to fix
    safe/report/expressions/infographic.py on lines 242..249
    safe/report/expressions/map_report.py on lines 374..381

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

    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_definition.get('need_parameter'):
                need = field_definition['need_parameter']
                if isinstance(need, ResourceParameter):
                    unit_abbreviation = need.unit.abbreviation
                    frequency = need.frequency
    Severity: Minor
    Found in safe/report/expressions/infographic.py and 1 other location - About 30 mins to fix
    safe/report/extractors/aggregate_postprocessors.py on lines 282..288

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

    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