inasafe/inasafe

View on GitHub
safe/utilities/metadata.py

Summary

Maintainability
F
4 days
Test Coverage

File metadata.py has 469 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8
"""Metadata Utilities."""
import logging
import os
from copy import deepcopy
Severity: Minor
Found in safe/utilities/metadata.py - About 7 hrs to fix

    Avoid too many return statements within this function.
    Open

        return None
    Severity: Major
    Found in safe/utilities/metadata.py - About 30 mins to fix

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

          keywords = {
              x[0]: x[1]['value'] for x in list(metadata.dict['properties'].items())
              if x[1]['value'] is not None}
      Severity: Major
      Found in safe/utilities/metadata.py and 1 other location - About 3 hrs to fix
      safe/utilities/metadata.py on lines 221..223

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

      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

          keywords = {
              x[0]: x[1]['value'] for x in list(metadata.dict['properties'].items())
              if x[1]['value'] is not None}
      Severity: Major
      Found in safe/utilities/metadata.py and 1 other location - About 3 hrs to fix
      safe/utilities/metadata.py on lines 235..237

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

      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 inasafe_fields.get(youth_ratio_field['key']):
                  new_keywords['youth ratio attribute'] = single_field(
                      inasafe_fields[youth_ratio_field['key']],
                      youth_ratio_field)
      Severity: Major
      Found in safe/utilities/metadata.py and 3 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 518..520
      safe/utilities/metadata.py on lines 521..524
      safe/utilities/metadata.py on lines 529..532

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

      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 inasafe_fields.get(elderly_ratio_field['key']):
                  new_keywords['elderly ratio attribute'] = single_field(
                      inasafe_fields[elderly_ratio_field['key']],
                      elderly_ratio_field)
      Severity: Major
      Found in safe/utilities/metadata.py and 3 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 518..520
      safe/utilities/metadata.py on lines 525..528
      safe/utilities/metadata.py on lines 529..532

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

      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 inasafe_fields.get(adult_ratio_field['key']):
                  new_keywords['adult ratio attribute'] = single_field(
                      inasafe_fields[adult_ratio_field['key']], adult_ratio_field)
      Severity: Major
      Found in safe/utilities/metadata.py and 3 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 521..524
      safe/utilities/metadata.py on lines 525..528
      safe/utilities/metadata.py on lines 529..532

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

      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 inasafe_fields.get(female_ratio_field['key']):
                  new_keywords['female ratio attribute'] = single_field(
                      inasafe_fields[female_ratio_field['key']],
                      female_ratio_field)
      Severity: Major
      Found in safe/utilities/metadata.py and 3 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 518..520
      safe/utilities/metadata.py on lines 521..524
      safe/utilities/metadata.py on lines 525..528

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

      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 raster_classification:
                          new_keywords[
                              'raster_hazard_classification'] = raster_classification
                          new_keywords['value_map'] = value_map
                      else:
      Severity: Major
      Found in safe/utilities/metadata.py and 1 other location - About 1 hr to fix
      safe/utilities/metadata.py on lines 506..512

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

      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 vector_classification:
                          new_keywords[
                              'vector_hazard_classification'] = vector_classification
                          new_keywords['value_map'] = value_map
                      else:
      Severity: Major
      Found in safe/utilities/metadata.py and 1 other location - About 1 hr to fix
      safe/utilities/metadata.py on lines 493..499

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

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

                  if inasafe_fields.get(exposure_name_field['key']):
                      new_keywords['area_name_field'] = inasafe_fields[
                          exposure_name_field['key']]
      Severity: Major
      Found in safe/utilities/metadata.py and 9 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 448..450
      safe/utilities/metadata.py on lines 456..458
      safe/utilities/metadata.py on lines 469..472
      safe/utilities/metadata.py on lines 473..474
      safe/utilities/metadata.py on lines 534..536
      safe/utilities/metadata.py on lines 538..540
      safe/utilities/metadata.py on lines 541..543
      safe/utilities/metadata.py on lines 544..546
      safe/utilities/metadata.py on lines 547..549

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

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

                  if inasafe_fields.get(exposure_id_field['key']):
                      new_keywords['area_id_field'] = inasafe_fields[
                          exposure_id_field['key']]
      Severity: Major
      Found in safe/utilities/metadata.py and 9 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 445..447
      safe/utilities/metadata.py on lines 456..458
      safe/utilities/metadata.py on lines 469..472
      safe/utilities/metadata.py on lines 473..474
      safe/utilities/metadata.py on lines 534..536
      safe/utilities/metadata.py on lines 538..540
      safe/utilities/metadata.py on lines 541..543
      safe/utilities/metadata.py on lines 544..546
      safe/utilities/metadata.py on lines 547..549

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

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

              if hazard == hazard_volcano['key']:
                  if inasafe_fields.get(hazard_name_field['key']):
                      new_keywords['volcano_name_field'] = inasafe_fields[
                          hazard_name_field['key']]
      Severity: Major
      Found in safe/utilities/metadata.py and 9 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 445..447
      safe/utilities/metadata.py on lines 448..450
      safe/utilities/metadata.py on lines 456..458
      safe/utilities/metadata.py on lines 473..474
      safe/utilities/metadata.py on lines 534..536
      safe/utilities/metadata.py on lines 538..540
      safe/utilities/metadata.py on lines 541..543
      safe/utilities/metadata.py on lines 544..546
      safe/utilities/metadata.py on lines 547..549

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

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

              if inasafe_default_values.get(elderly_ratio_field['key']):
                  new_keywords['elderly ratio default'] = inasafe_default_values[
                      elderly_ratio_field['key']]
      Severity: Major
      Found in safe/utilities/metadata.py and 9 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 445..447
      safe/utilities/metadata.py on lines 448..450
      safe/utilities/metadata.py on lines 456..458
      safe/utilities/metadata.py on lines 469..472
      safe/utilities/metadata.py on lines 473..474
      safe/utilities/metadata.py on lines 534..536
      safe/utilities/metadata.py on lines 538..540
      safe/utilities/metadata.py on lines 544..546
      safe/utilities/metadata.py on lines 547..549

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

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

              if inasafe_default_values.get(female_ratio_field['key']):
                  new_keywords['female ratio default'] = inasafe_default_values[
                      female_ratio_field['key']]
      Severity: Major
      Found in safe/utilities/metadata.py and 9 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 445..447
      safe/utilities/metadata.py on lines 448..450
      safe/utilities/metadata.py on lines 456..458
      safe/utilities/metadata.py on lines 469..472
      safe/utilities/metadata.py on lines 473..474
      safe/utilities/metadata.py on lines 534..536
      safe/utilities/metadata.py on lines 538..540
      safe/utilities/metadata.py on lines 541..543
      safe/utilities/metadata.py on lines 544..546

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

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

              if inasafe_fields.get(exposure_name_field['key']):
                  new_keywords['name_field'] = inasafe_fields[
                      exposure_name_field['key']]
      Severity: Major
      Found in safe/utilities/metadata.py and 9 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 445..447
      safe/utilities/metadata.py on lines 448..450
      safe/utilities/metadata.py on lines 469..472
      safe/utilities/metadata.py on lines 473..474
      safe/utilities/metadata.py on lines 534..536
      safe/utilities/metadata.py on lines 538..540
      safe/utilities/metadata.py on lines 541..543
      safe/utilities/metadata.py on lines 544..546
      safe/utilities/metadata.py on lines 547..549

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

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

              if inasafe_fields.get(hazard_value_field['key']):
                  new_keywords['field'] = inasafe_fields[hazard_value_field['key']]
      Severity: Major
      Found in safe/utilities/metadata.py and 9 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 445..447
      safe/utilities/metadata.py on lines 448..450
      safe/utilities/metadata.py on lines 456..458
      safe/utilities/metadata.py on lines 469..472
      safe/utilities/metadata.py on lines 534..536
      safe/utilities/metadata.py on lines 538..540
      safe/utilities/metadata.py on lines 541..543
      safe/utilities/metadata.py on lines 544..546
      safe/utilities/metadata.py on lines 547..549

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

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

              if inasafe_fields.get(aggregation_name_field['key']):
                  new_keywords['aggregation attribute'] = inasafe_fields[
                      aggregation_name_field['key']]
      Severity: Major
      Found in safe/utilities/metadata.py and 9 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 445..447
      safe/utilities/metadata.py on lines 448..450
      safe/utilities/metadata.py on lines 456..458
      safe/utilities/metadata.py on lines 469..472
      safe/utilities/metadata.py on lines 473..474
      safe/utilities/metadata.py on lines 538..540
      safe/utilities/metadata.py on lines 541..543
      safe/utilities/metadata.py on lines 544..546
      safe/utilities/metadata.py on lines 547..549

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

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

              if inasafe_default_values.get(adult_ratio_field['key']):
                  new_keywords['adult ratio default'] = inasafe_default_values[
                      adult_ratio_field['key']]
      Severity: Major
      Found in safe/utilities/metadata.py and 9 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 445..447
      safe/utilities/metadata.py on lines 448..450
      safe/utilities/metadata.py on lines 456..458
      safe/utilities/metadata.py on lines 469..472
      safe/utilities/metadata.py on lines 473..474
      safe/utilities/metadata.py on lines 534..536
      safe/utilities/metadata.py on lines 541..543
      safe/utilities/metadata.py on lines 544..546
      safe/utilities/metadata.py on lines 547..549

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

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

              if inasafe_default_values.get(youth_ratio_field['key']):
                  new_keywords['youth ratio default'] = inasafe_default_values[
                      youth_ratio_field['key']]
      Severity: Major
      Found in safe/utilities/metadata.py and 9 other locations - About 1 hr to fix
      safe/utilities/metadata.py on lines 445..447
      safe/utilities/metadata.py on lines 448..450
      safe/utilities/metadata.py on lines 456..458
      safe/utilities/metadata.py on lines 469..472
      safe/utilities/metadata.py on lines 473..474
      safe/utilities/metadata.py on lines 534..536
      safe/utilities/metadata.py on lines 538..540
      safe/utilities/metadata.py on lines 541..543
      safe/utilities/metadata.py on lines 547..549

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

      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

                  elif exposure == exposure_road['key']:
                      new_keywords['road_class_field'] = exposure_class_field
                  else:
                      if exposure == exposure_land_cover['key']:
                          new_keywords['field'] = exposure_class_field
      Severity: Major
      Found in safe/utilities/metadata.py and 1 other location - About 1 hr to fix
      safe/gui/tools/wizard/step_kw33_multi_classifications.py on lines 1228..1231

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

      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