inasafe/inasafe

View on GitHub
safe/gui/tools/options_dialog.py

Summary

Maintainability
F
6 days
Test Coverage

File options_dialog.py has 760 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8
"""InaSAFE Options Dialog."""


import logging
Severity: Major
Found in safe/gui/tools/options_dialog.py - About 1 day to fix

    OptionsDialog has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class OptionsDialog(QDialog, FORM_CLASS):
    
        """Options dialog for the InaSAFE plugin."""
    
        def __init__(self, iface, parent=None, qsetting=''):
    Severity: Minor
    Found in safe/gui/tools/options_dialog.py - About 4 hrs to fix

      Function __init__ has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, iface, parent=None, qsetting=''):
              """Constructor for the dialog.
      
              :param iface: A Quantum GIS QgisAppInterface instance.
              :type iface: QgisAppInterface
      Severity: Major
      Found in safe/gui/tools/options_dialog.py - About 2 hrs to fix

        Function restore_state has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def restore_state(self):
                """Reinstate the options based on the user's stored session info."""
                # Restore boolean setting as check box.
                for key, check_box in list(self.boolean_settings.items()):
                    self.restore_boolean_setting(key, check_box)
        Severity: Minor
        Found in safe/gui/tools/options_dialog.py - About 1 hr to fix

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

              def show_help(self):
                  """Show usage info to the user."""
                  # Read the header and footer html snippets
                  self.main_stacked_widget.setCurrentIndex(0)
                  header = html_header()
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 10 other locations - About 4 hrs to fix
          safe/gui/tools/batch/batch_dialog.py on lines 832..846
          safe/gui/tools/extent_selector_dialog.py on lines 189..203
          safe/gui/tools/field_mapping_dialog.py on lines 227..241
          safe/gui/tools/minimum_needs/needs_calculator_dialog.py on lines 270..284
          safe/gui/tools/minimum_needs/needs_manager_dialog.py on lines 845..859
          safe/gui/tools/multi_buffer_dialog.py on lines 277..291
          safe/gui/tools/osm_downloader_dialog.py on lines 202..215
          safe/gui/tools/peta_bencana_dialog.py on lines 157..173
          safe/gui/tools/print_report_dialog.py on lines 598..615
          safe/gui/tools/shake_grid/shakemap_converter_dialog.py on lines 372..386

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

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

              @pyqtSlot(bool)  # prevents actions being handled twice
              def help_toggled(self, flag):
                  """Show or hide the help tab in the stacked widget.
          
                  .. versionadded: 3.2.1
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 7 other locations - About 3 hrs to fix
          safe/gui/tools/batch/batch_dialog.py on lines 809..823
          safe/gui/tools/extent_selector_dialog.py on lines 166..180
          safe/gui/tools/field_mapping_dialog.py on lines 204..218
          safe/gui/tools/minimum_needs/needs_calculator_dialog.py on lines 247..261
          safe/gui/tools/minimum_needs/needs_manager_dialog.py on lines 822..836
          safe/gui/tools/multi_buffer_dialog.py on lines 259..271
          safe/gui/tools/peta_bencana_dialog.py on lines 134..148

          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

                  for i in reversed(list(range(self.container_layout.count()))):
                      widget = self.container_layout.itemAt(i).widget()
                      if widget is not None:
                          widget.setParent(None)
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 1 other location - About 2 hrs to fix
          safe/gui/tools/options_dialog.py on lines 850..853

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

          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

                  for i in reversed(list(range(self.container_layout.count()))):
                      widget = self.container_layout.itemAt(i).widget()
                      if widget is not None:
                          widget.setParent(None)
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 1 other location - About 2 hrs to fix
          safe/gui/tools/options_dialog.py on lines 701..704

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

          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

              def open_organisation_logo_path(self):
                  """Open File dialog to choose the organisation logo path."""
                  # noinspection PyCallByClass,PyTypeChecker
                  file_name, __ = QFileDialog.getOpenFileName(
                      self,
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 2 other locations - About 2 hrs to fix
          safe/gui/tools/options_dialog.py on lines 487..496
          safe/gui/tools/options_dialog.py on lines 509..522

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

          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

              def open_north_arrow_path(self):
                  """Open File dialog to choose the north arrow path."""
                  # noinspection PyCallByClass,PyTypeChecker
                  file_name, __ = QFileDialog.getOpenFileName(
                      self,
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 2 other locations - About 2 hrs to fix
          safe/gui/tools/options_dialog.py on lines 487..496
          safe/gui/tools/options_dialog.py on lines 524..537

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

          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

              def open_keyword_cache_path(self):
                  """Open File dialog to choose the keyword cache path."""
                  # noinspection PyCallByClass,PyTypeChecker
                  file_name, __ = QFileDialog.getSaveFileName(
                      self,
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 2 other locations - About 2 hrs to fix
          safe/gui/tools/options_dialog.py on lines 509..522
          safe/gui/tools/options_dialog.py on lines 524..537

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

          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

              def open_user_directory_path(self):
                  """Open File dialog to choose the user directory path."""
                  # noinspection PyCallByClass,PyTypeChecker
                  directory_name = QFileDialog.getExistingDirectory(
                      self,
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 1 other location - About 2 hrs to fix
          safe/gui/tools/options_dialog.py on lines 539..548

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

          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

              def open_report_template_path(self):
                  """Open File dialog to choose the report template path."""
                  # noinspection PyCallByClass,PyTypeChecker
                  directory_name = QFileDialog.getExistingDirectory(
                      self,
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 1 other location - About 2 hrs to fix
          safe/gui/tools/options_dialog.py on lines 498..507

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

          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

              def restore_boolean_setting(self, key, check_box):
                  """Set check_box according to setting of key.
          
                  :param key: Key to retrieve setting value.
                  :type key: str
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 1 other location - About 1 hr to fix
          safe/gui/tools/options_dialog.py on lines 290..300

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

          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

              def restore_text_setting(self, key, line_edit):
                  """Set line_edit text according to setting of key.
          
                  :param key: Key to retrieve setting value.
                  :type key: str
          Severity: Major
          Found in safe/gui/tools/options_dialog.py and 1 other location - About 1 hr to fix
          safe/gui/tools/options_dialog.py on lines 267..277

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

          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 is_checked:
                      # Use previous org logo path
                      path = setting(
                          key='organisation_logo_path',
                          default=supporters_logo_path(),
          Severity: Minor
          Found in safe/gui/tools/options_dialog.py and 1 other location - About 50 mins to fix
          safe/gui/tools/options_dialog.py on lines 585..594

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

          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 is_checked:
                      # Show previous north arrow path
                      path = setting(
                          key='north_arrow_path',
                          default=default_north_arrow_path(),
          Severity: Minor
          Found in safe/gui/tools/options_dialog.py and 1 other location - About 50 mins to fix
          safe/gui/tools/options_dialog.py on lines 553..562

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

          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