svthalia/concrexit

View on GitHub
website/sales/admin/order_admin.py

Summary

Maintainability
C
7 hrs
Test Coverage

File order_admin.py has 334 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from functools import partial

from django.contrib import admin, messages
from django.contrib.admin import SimpleListFilter, register
from django.forms import Field
Severity: Minor
Found in website/sales/admin/order_admin.py - About 4 hrs to fix

Function formfield_for_dbfield has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def formfield_for_dbfield(self, db_field, request, obj=None, **kwargs):
Severity: Minor
Found in website/sales/admin/order_admin.py - About 35 mins to fix

Function save_model has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def save_model(self, request, obj, form, change):
Severity: Minor
Found in website/sales/admin/order_admin.py - About 35 mins to fix

Function change_view has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def change_view(self, request, object_id, form_url="", extra_context=None):
Severity: Minor
Found in website/sales/admin/order_admin.py - About 35 mins to fix

Function changeform_view has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def changeform_view(self, request, object_id=None, form_url="", extra_context=None):
Severity: Minor
Found in website/sales/admin/order_admin.py - About 35 mins to fix

Function formfield_for_foreignkey has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
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":
Severity: Minor
Found in website/sales/admin/order_admin.py - About 35 mins to fix

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

    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 (
Severity: Minor
Found in website/sales/admin/order_admin.py - About 25 mins to fix

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

There are no issues that match your filters.

Category
Status