CodeTheChangeUBC/reBOOT

View on GitHub
app/admin.py

Summary

Maintainability
A
2 hrs
Test Coverage

File admin.py has 418 lines of code (exceeds 300 allowed). Consider refactoring.
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
Severity: Minor
Found in app/admin.py - About 4 hrs to fix

    Function response_change has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    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()
    Severity: Minor
    Found in app/admin.py - About 1 hr 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 generate_receipt_policy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    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]):
    Severity: Minor
    Found in app/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

    Avoid too many return statements within this function.
    Open

                return super().response_change(req, obj)
    Severity: Major
    Found in app/admin.py - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status