File services.py
has 475 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
from django.conf import settings
from django.contrib.admin.utils import model_ngettext
from django.contrib.contenttypes.models import ContentType
- Create a ticketCreate a ticket
Function create_or_update_external_invoice
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def create_or_update_external_invoice(obj):
"""Create an external sales invoice on Moneybird for a payable object."""
if not settings.MONEYBIRD_SYNC_ENABLED:
return None
- 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 _sync_contacts
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _sync_contacts():
logger.info("Synchronizing contacts...")
# Make moneybird contacts for people that dont have.
for member in Member.objects.filter(
moneybird_contact__isnull=True, profile__is_minimized=False
- 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 create_or_update_contact
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create_or_update_contact(member: Member):
"""Push a Django user/member to Moneybird."""
if not settings.MONEYBIRD_SYNC_ENABLED:
return None
- 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 _sync_outdated_invoices
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _sync_outdated_invoices():
"""Resynchronize all invoices that have been marked as outdated."""
invoices = MoneybirdExternalInvoice.objects.filter(
needs_synchronization=True, needs_deletion=False
).order_by("payable_model", "object_id")
- 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 delete_contact
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def delete_contact(contact: MoneybirdContact):
"""Delete or archive a contact on Moneybird, and delete our record of it."""
if not settings.MONEYBIRD_SYNC_ENABLED:
return
- 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 _sync_moneybird_payments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _sync_moneybird_payments():
"""Create financial statements with all payments that haven't been synced yet.
This creates one statement per payment type for which there are new payments.
"""
- 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"