inasafe/inasafe

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

Summary

Maintainability
F
3 days
Test Coverage

File step_kw40_classify.py has 284 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8
"""InaSAFE Wizard Step Value Mapping."""


import json
Severity: Minor
Found in safe/gui/tools/wizard/step_kw40_classify.py - About 2 hrs to fix

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

                for value in assigned_values[default_class['key']]:
                    string_value = value is not None and str(value) or 'NULL'
                    tree_leaf = QTreeWidgetItem(tree_branch)
                    tree_leaf.setFlags(
                        Qt.ItemIsEnabled
    Severity: Major
    Found in safe/gui/tools/wizard/step_kw40_classify.py and 1 other location - About 6 hrs to fix
    safe/gui/tools/wizard/step_kw33_multi_classifications.py on lines 1022..1030

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

    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 selected_mapping(self):
            """Obtain the value-to-class mapping set by user.
    
            :returns: The complete mapping as a dict of lists.
            :rtype: dict
    Severity: Major
    Found in safe/gui/tools/wizard/step_kw40_classify.py and 1 other location - About 6 hrs to fix
    safe/gui/tools/wizard/step_kw33_multi_classifications.py on lines 1130..1144

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

    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

                    if 'string_defaults' in default_class:
                        # To make it case insensitive
                        upper_string_defaults = [
                            c.upper() for c in default_class['string_defaults']]
                        in_string_default = (
    Severity: Major
    Found in safe/gui/tools/wizard/step_kw40_classify.py and 1 other location - About 3 hrs to fix
    safe/gui/tools/wizard/step_kw33_multi_classifications.py on lines 871..879

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

    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

            if int(item.flags() & Qt.ItemIsDropEnabled) \
                    and int(item.flags() & Qt.ItemIsDragEnabled):
                item.setFlags(item.flags() & ~Qt.ItemIsDropEnabled)
    Severity: Major
    Found in safe/gui/tools/wizard/step_kw40_classify.py and 1 other location - About 3 hrs to fix
    safe/gui/tools/wizard/step_kw33_multi_classifications.py on lines 956..958

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

    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

                for key, value_list in list(value_map.items()):
                    if unique_value in value_list and key in assigned_values:
                        assigned_values[key] += [unique_value]
                        assigned = True
    Severity: Major
    Found in safe/gui/tools/wizard/step_kw40_classify.py and 1 other location - About 2 hrs to fix
    safe/gui/tools/wizard/step_kw33_multi_classifications.py on lines 929..932

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

    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

                if numpy.issubdtype(unique_values.dtype, float):
                    unique_values = [float(i) for i in unique_values]
                else:
                    unique_values = [int(i) for i in unique_values]
    Severity: Major
    Found in safe/gui/tools/wizard/step_kw40_classify.py and 1 other location - About 1 hr to fix
    safe/gui/tools/wizard/step_kw33_multi_classifications.py on lines 816..819

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

    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 layer_purpose['key'] != layer_purpose_aggregation['key']:
                subcategory = self.parent.step_kw_subcategory. \
                    selected_subcategory()
            else:
                subcategory = {'key': None}
    Severity: Major
    Found in safe/gui/tools/wizard/step_kw40_classify.py and 2 other locations - About 1 hr to fix
    safe/gui/tools/wizard/step_kw43_threshold.py on lines 68..72
    safe/gui/tools/wizard/step_kw45_inasafe_fields.py on lines 61..65

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

    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 __init__(self, parent=None):
            """Constructor for the tab.
    
            :param parent: parent - widget to use as parent (Wizard Dialog).
            :type parent: QWidget
    Severity: Minor
    Found in safe/gui/tools/wizard/step_kw40_classify.py and 1 other location - About 55 mins to fix
    safe/gui/tools/wizard/step_kw13_band_selector.py on lines 30..38

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

    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

                if 'name' in default_class:
                    default_class_name = default_class['name']
                else:
                    default_class_name = default_class['key']
    Severity: Minor
    Found in safe/gui/tools/wizard/step_kw40_classify.py and 1 other location - About 35 mins to fix
    safe/gui/tools/wizard/step_kw33_multi_classifications.py on lines 1013..1016

    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