inasafe/inasafe

View on GitHub
safe/gui/tools/wizard/wizard_dialog.py

Summary

Maintainability
F
4 days
Test Coverage

File wizard_dialog.py has 710 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8
"""Wizard Dialog."""


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

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

        def __init__(self, parent=None, iface=None, dock=None):
            """Constructor for the dialog.
    
            .. note:: In QtDesigner the advanced editor's predefined keywords
               list should be shown in english always, so when adding entries to
    Severity: Major
    Found in safe/gui/tools/wizard/wizard_dialog.py - About 4 hrs to fix

      WizardDialog has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class WizardDialog(QDialog, FORM_CLASS):
          """Dialog implementation class for the InaSAFE wizard."""
      
          resized = pyqtSignal()
      
      
      Severity: Minor
      Found in safe/gui/tools/wizard/wizard_dialog.py - About 2 hrs to fix

        Function get_keywords has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def get_keywords(self):
                """Obtain the state of the dialog as a keywords dict.
        
                :returns: Keywords reflecting the state of the dialog.
                :rtype: dict
        Severity: Minor
        Found in safe/gui/tools/wizard/wizard_dialog.py - About 1 hr to fix

          Avoid too many return statements within this function.
          Open

                      return False
          Severity: Major
          Found in safe/gui/tools/wizard/wizard_dialog.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return True
            Severity: Major
            Found in safe/gui/tools/wizard/wizard_dialog.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return True
              Severity: Major
              Found in safe/gui/tools/wizard/wizard_dialog.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return True
                Severity: Major
                Found in safe/gui/tools/wizard/wizard_dialog.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return False
                  Severity: Major
                  Found in safe/gui/tools/wizard/wizard_dialog.py - About 30 mins to fix

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

                                try:
                                    keywords = self.keyword_io.read_keywords(layer)
                                    if 'layer_purpose' not in keywords:
                                        keywords = None
                                except (HashNotFoundError,
                    Severity: Major
                    Found in safe/gui/tools/wizard/wizard_dialog.py and 2 other locations - About 1 hr to fix
                    safe/gui/tools/wizard/wizard_dialog.py on lines 394..405
                    safe/gui/tools/wizard/wizard_dialog.py on lines 540..550

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 47.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

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

                            try:
                                keywords = self.keyword_io.read_keywords(layer)
                                if 'layer_purpose' not in keywords:
                                    keywords = None
                            except (HashNotFoundError,
                    Severity: Major
                    Found in safe/gui/tools/wizard/wizard_dialog.py and 2 other locations - About 1 hr to fix
                    safe/gui/tools/wizard/wizard_dialog.py on lines 394..405
                    safe/gui/tools/wizard/wizard_dialog.py on lines 469..479

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 47.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

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

                            if not keywords:
                                try:
                                    keywords = self.keyword_io.read_keywords(layer)
                                    if 'layer_purpose' not in keywords:
                                        keywords = None
                    Severity: Major
                    Found in safe/gui/tools/wizard/wizard_dialog.py and 2 other locations - About 1 hr to fix
                    safe/gui/tools/wizard/wizard_dialog.py on lines 469..479
                    safe/gui/tools/wizard/wizard_dialog.py on lines 540..550

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 47.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

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

                        def after_resize(self):
                            """Method after resizing the window."""
                            # Reset the max height. 190 is a number that make it pretty
                            max_height = self.height() - 190
                            self.scrollAreaWidgetContents.setMaximumHeight(max_height)
                    Severity: Minor
                    Found in safe/gui/tools/wizard/wizard_dialog.py and 1 other location - About 45 mins to fix
                    safe/gui/tools/metadata_converter_dialog.py on lines 345..350

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

                    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 self.step_kw_layermode.selected_layermode():
                                keywords['layer_mode'] = self.step_kw_layermode.\
                    Severity: Major
                    Found in safe/gui/tools/wizard/wizard_dialog.py and 3 other locations - About 35 mins to fix
                    safe/gui/tools/wizard/wizard_dialog.py on lines 747..748
                    safe/gui/tools/wizard/wizard_dialog.py on lines 758..761
                    safe/gui/tools/wizard/wizard_dialog.py on lines 775..776

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

                    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 keywords['layer_purpose'] == layer_purpose_hazard['key']:
                                if self.step_kw_hazard_category.selected_hazard_category():
                                    keywords['hazard_category'] \
                                        = self.step_kw_hazard_category.\
                    Severity: Major
                    Found in safe/gui/tools/wizard/wizard_dialog.py and 3 other locations - About 35 mins to fix
                    safe/gui/tools/wizard/wizard_dialog.py on lines 747..748
                    safe/gui/tools/wizard/wizard_dialog.py on lines 763..764
                    safe/gui/tools/wizard/wizard_dialog.py on lines 775..776

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

                    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 self.step_kw_purpose.selected_purpose():
                                keywords['layer_purpose'] = self.step_kw_purpose.\
                    Severity: Major
                    Found in safe/gui/tools/wizard/wizard_dialog.py and 3 other locations - About 35 mins to fix
                    safe/gui/tools/wizard/wizard_dialog.py on lines 758..761
                    safe/gui/tools/wizard/wizard_dialog.py on lines 763..764
                    safe/gui/tools/wizard/wizard_dialog.py on lines 775..776

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

                    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 self.step_kw_classification.selected_classification():
                                keywords['classification'] = self.step_kw_classification.\
                    Severity: Major
                    Found in safe/gui/tools/wizard/wizard_dialog.py and 3 other locations - About 35 mins to fix
                    safe/gui/tools/wizard/wizard_dialog.py on lines 747..748
                    safe/gui/tools/wizard/wizard_dialog.py on lines 758..761
                    safe/gui/tools/wizard/wizard_dialog.py on lines 763..764

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

                    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 resizeEvent(self, event):
                            """Emit custom signal when the window is re-sized.
                    
                            :param event: The re-sized event.
                            :type event: QResizeEvent
                    Severity: Minor
                    Found in safe/gui/tools/wizard/wizard_dialog.py and 1 other location - About 35 mins to fix
                    safe/gui/tools/metadata_converter_dialog.py on lines 336..343

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

                    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