Function get_all_form_components
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def get_all_form_components(form: Form):
components = []
for component in form.questions:
if component and hasattr(component, "name"):
components.append(component)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function insert_hidden_fields
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def insert_hidden_fields(data: dict, form: Form):
for key, value in data.items():
add = True
# Only add hidden fields if the data isn't already being passed through a component
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function heading_used_as_label
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def heading_used_as_label(components):
single_input = None
if components:
for component in components:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
for _component in option.components:
if _component and hasattr(_component, "name"):
components.append(_component)
Function flatten_data
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def flatten_data(d, parent_key="", sep="."):
"""
Flattens dictionaries eg
{
'site': {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function remove_unused_errors
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def remove_unused_errors(errors, form: Form):
"""
Removes all errors that don't belong to a form's fields
:param errors: ['errors'] children
:param form: Form object
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function convert_list_to_tree
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def convert_list_to_tree(items, key="key", value="value", children="children", exclude=None):
return_value = []
for item in items:
node = TreeNode(item[key], item[value])
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function nest_data
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def nest_data(sent_data):
"""
Nests strings into dictionaries eg
{
'site.name': 'SITE1'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"