Function _tree_flattend
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
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)
Function build_header
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
def build_header(self, data, parent_key=None):
header = []
if isinstance(data, dict):
for colname, colvalue in data.items():
Function get_ordering
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
def get_ordering(self, request, queryset, view):
ordering = super().get_ordering(request, queryset, view)
if not ordering:
ordering = []
Function get_media_response
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def get_media_response(request, data, permissions=None, headers=None):
content, url = None, None
if isinstance(data, (File, )):
content, url = data, data.url
Avoid deeply nested control flow statements.
if sub_child.keys() <= sub_tree.keys():
subtree_copy = deepcopy(sub_tree)
subtree_copy.update(sub_child)
flatten_tree.append(subtree_copy)
break
Function VALUE_TO_CONST
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def VALUE_TO_CONST(self):
"""
Dict {"value": "const"}
"""
if self._VALUE_TO_CONST is None:
Function REVERTED_CHOICES_DICT
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def REVERTED_CHOICES_DICT(self):
"""
Dict {"display_value": "value"}
"""
Function handle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
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:')
Function CHOICES_DICT
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
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: