app/api/orders.py
File orders.py
has 760 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import json
import logging
import time
import omise
- Create a ticketCreate a ticket
Function before_update_object
has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring. Open
Open
def before_update_object(self, order, data, view_kwargs):
"""
before update object method of order details
1. admin can update all the fields.
2. event organizer
- 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
Avoid deeply nested control flow statements. Open
Open
if element not in relationships and data[element] != getattr(
order, element, None
):
if element != 'status':
raise ForbiddenError(
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if (
element not in relationships
and data[element] != getattr(order, element, None)
and element not in get_updatable_fields()
):
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
Open
if data.get('is_billing_enabled') and not (
data.get('company')
and data.get('address')
and data.get('city')
and data.get('zipcode')
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
Open
if mode == 'stripe':
return (
(order.paid_via == 'stripe')
and order.brand
and order.transaction_id
- Create a ticketCreate a ticket
Function check_event_user_ticket_holders
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def check_event_user_ticket_holders(order, data, element):
if element in ['event', 'user'] and data[element] != str(
getattr(order, element, None).id
):
raise ForbiddenError(
- 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"