app/admin.py
File admin.py
has 418 lines of code (exceeds 300 allowed). Consider refactoring. Wontfix
Wontfix
# -*- coding: utf-8 -*-
from django.contrib import admin, messages
from django.db import models
from django.forms import Textarea
from django.http import HttpRequest, HttpResponseRedirect
Function response_change
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def response_change(self, req: HttpRequest, obj):
if "_generate_receipt" in req.POST or \
"_mark_items_verified" in req.POST or \
"_mark_items_unverified" in req.POST:
obj.save()
- 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 generate_receipt_policy
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def generate_receipt_policy(self, req, qs):
err = None
if not req.user.has_perm('app.generate_tax_receipt'):
err = PERMISSION_DENIED
elif not all([d.is_items_received() for d in qs]):
- 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 too many return
statements within this function. Open
Open
return super().response_change(req, obj)