File admin.py
has 643 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Registers admin interfaces for the payments module."""
import csv
from collections import OrderedDict
from django.contrib import admin, messages
- Create a ticketCreate a ticket
Function has_delete_permission
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def has_delete_permission(self, request, obj=None):
if isinstance(obj, Payment):
if obj.batch and obj.batch.processed:
return False
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"
Further reading
Function has_delete_permission
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def has_delete_permission(self, request, obj=None):
if isinstance(obj, Batch):
if obj.processed:
return False
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"
Further reading
Function _show_message
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _show_message(
- Create a ticketCreate a ticket
Function export_csv
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def export_csv(self, request: HttpRequest, queryset: QuerySet) -> HttpResponse:
"""Export a CSV of payments.
:param request: Request
:param queryset: Items to be exported
- 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 add_to_last_batch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_to_last_batch(self, request: HttpRequest, queryset: QuerySet) -> None:
"""Add selected TPAY payments to the last batch."""
tpays = queryset.filter(type=Payment.TPAY)
if len(tpays) > 0:
batch = Batch.objects.last()
- 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"