Terralego/django-terra-utils

View on GitHub
terra_utils/helpers/__init__.py

Summary

Maintainability
C
7 hrs
Test Coverage

Showing 11 of 15 total issues

Function _tree_flattend has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def _tree_flattend(self, flatten_tree, tree, parent='', sep='_'):
for node, child in tree.items():
parent_node = node if not parent else sep.join((parent, node))
flatten_child = self.flatten_datatree(child,
parent=parent_node)
Severity: Minor
Found in terra_utils/helpers/__init__.py - About 3 hrs to fix

Function build_header has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def build_header(self, data, parent_key=None):
header = []
 
if isinstance(data, dict):
for colname, colvalue in data.items():
Severity: Minor
Found in terra_utils/helpers/__init__.py - About 2 hrs to fix

Cyclomatic complexity is too high in method build_header. (9)
Open

def build_header(self, data, parent_key=None):
header = []
 
if isinstance(data, dict):
for colname, colvalue in data.items():
Severity: Minor
Found in terra_utils/helpers/__init__.py by radon

Cyclomatic complexity is too high in method _tree_flattend. (9)
Open

def _tree_flattend(self, flatten_tree, tree, parent='', sep='_'):
for node, child in tree.items():
parent_node = node if not parent else sep.join((parent, node))
flatten_child = self.flatten_datatree(child,
parent=parent_node)
Severity: Minor
Found in terra_utils/helpers/__init__.py by radon

Avoid deeply nested control flow statements.
Open

if sub_child.keys() <= sub_tree.keys():
subtree_copy = deepcopy(sub_tree)
subtree_copy.update(sub_child)
flatten_tree.append(subtree_copy)
break
Severity: Major
Found in terra_utils/helpers/__init__.py - About 45 mins to fix

    Function VALUE_TO_CONST has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def VALUE_TO_CONST(self):
    """
    Dict {"value": "const"}
    """
    if self._VALUE_TO_CONST is None:
    Severity: Minor
    Found in terra_utils/helpers/__init__.py - About 25 mins to fix

    Function REVERTED_CHOICES_DICT has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def REVERTED_CHOICES_DICT(self):
    """
    Dict {"display_value": "value"}
    """
    # FIXME: rename in a more friendly name, like STRING_TO_VALUE?
    Severity: Minor
    Found in terra_utils/helpers/__init__.py - About 25 mins to fix

    Function CHOICES_DICT has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def CHOICES_DICT(self):
    if self._CHOICES_DICT is None:
    self._CHOICES_DICT = {}
    for c, k, v in self.RAW_CHOICES:
    if c in self._CONSTS:
    Severity: Minor
    Found in terra_utils/helpers/__init__.py - About 25 mins to fix

    Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed.
    Open

    def build_header(self, data, parent_key=None):
    Severity: Critical
    Found in terra_utils/helpers/__init__.py by sonar-python

    Refactor this function to reduce its Cognitive Complexity from 24 to the 15 allowed.
    Open

    def _tree_flattend(self, flatten_tree, tree, parent='', sep='_'):
    Severity: Critical
    Found in terra_utils/helpers/__init__.py by sonar-python

    Take the required action to fix the issue indicated by this "FIXME" comment.
    Open

    # FIXME: rename in a more friendly name, like STRING_TO_VALUE?

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

    @property
    def VALUE_TO_CONST(self):
    """
    Dict {"value": "const"}
    """
    Severity: Major
    Found in terra_utils/helpers/__init__.py and 1 other location - About 3 hrs to fix
    terra_utils/helpers/__init__.py on lines 228..239

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

    @property
    def REVERTED_CHOICES_DICT(self):
    """
    Dict {"display_value": "value"}
    """
    Severity: Major
    Found in terra_utils/helpers/__init__.py and 1 other location - About 3 hrs to fix
    terra_utils/helpers/__init__.py on lines 241..251

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

    @property
    def CHOICES(self):
    """
    Tuple of tuples (value, display_value).
    """
    Severity: Major
    Found in terra_utils/helpers/__init__.py and 1 other location - About 3 hrs to fix
    terra_utils/helpers/__init__.py on lines 253..261

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

    @property
    def CONST_CHOICES(self):
    """
    Tuple of tuples (constant, display_value).
    """
    Severity: Major
    Found in terra_utils/helpers/__init__.py and 1 other location - About 3 hrs to fix
    terra_utils/helpers/__init__.py on lines 209..217
    Category
    Status