svthalia/concrexit

View on GitHub
website/payments/admin.py

Summary

Maintainability
D
1 day
Test Coverage

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
Severity: Major
Found in website/payments/admin.py - About 1 day to fix

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 (
Severity: Minor
Found in website/payments/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 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 (
Severity: Minor
Found in website/payments/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 _show_message has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def _show_message(
Severity: Minor
Found in website/payments/admin.py - About 35 mins to fix

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
Severity: Minor
Found in website/payments/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 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()
Severity: Minor
Found in website/payments/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