website/sales/admin/order_admin.py
File order_admin.py
has 334 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
from functools import partial
from django.contrib import admin, messages
from django.contrib.admin import SimpleListFilter, register
from django.forms import Field
- Create a ticketCreate a ticket
Function formfield_for_dbfield
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def formfield_for_dbfield(self, db_field, request, obj=None, **kwargs):
- Create a ticketCreate a ticket
Function save_model
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def save_model(self, request, obj, form, change):
- Create a ticketCreate a ticket
Function change_view
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def change_view(self, request, object_id, form_url="", extra_context=None):
- Create a ticketCreate a ticket
Function changeform_view
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def changeform_view(self, request, object_id=None, form_url="", extra_context=None):
- Create a ticketCreate a ticket
Function formfield_for_foreignkey
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
"""Limit product list items to items of order's shift."""
field = super().formfield_for_foreignkey(db_field, request, **kwargs)
if db_field.name == "product":
- Read upRead up
- Create a ticketCreate a ticket
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 change_view
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def change_view(self, request, object_id, form_url="", extra_context=None):
if object_id:
try:
obj = self.model.objects.get(pk=object_id)
if (
- Read upRead up
- Create a ticketCreate a ticket
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"