File admin.py
has 466 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
from copy import deepcopy
from datetime import datetime
from typing import Dict, Any
Function save_model
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def save_model(self, request, obj, form, change):
# allows to place a new item at the right position, moving certain items up.
# if the display_order is zero, autoplace the item.
if obj.display_order:
- 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 add_configuration
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_configuration(country: str, organization_type: int):
if models.Configuration.objects.all().filter(country=country, organization_type=organization_type).exists():
log.debug("This configuration already exists, skipping.")
return
- 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 reorder
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def reorder(self, request, queryset):
first_order = None
for configuration in queryset:
- 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"