Terralego/django-terra-utils

View on GitHub

Showing 9 of 25 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

Function get_ordering has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def get_ordering(self, request, queryset, view):
ordering = super().get_ordering(request, queryset, view)
 
if not ordering:
ordering = []
Severity: Minor
Found in terra_utils/filters.py - About 1 hr to fix

Function get_media_response has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_media_response(request, data, permissions=None, headers=None):
# For compatibility purpose
content, url = None, None
if isinstance(data, (File, )):
content, url = data, data.url
Severity: Minor
Found in terra_utils/helpers/responses.py - About 1 hr to fix

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 handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def handle(self, *args, **options):
    self.test_mode = True if options.get('test_data') else False
     
    if options.get('list', False):
    self.stdout.write('Applications with populate modules:')
    Severity: Minor
    Found in terra_utils/management/commands/populatedata.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
    Severity
    Category
    Status
    Source
    Language