fossasia/open-event-orga-server

View on GitHub
app/api/orders.py

Summary

Maintainability
F
3 days
Test Coverage

File orders.py has 760 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import logging
import time

import omise
Severity: Major
Found in app/api/orders.py - About 1 day to fix

Function before_update_object has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
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
Severity: Minor
Found in app/api/orders.py - About 1 day 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 deeply nested control flow statements.
Open

                        if element not in relationships and data[element] != getattr(
                            order, element, None
                        ):
                            if element != 'status':
                                raise ForbiddenError(
Severity: Major
Found in app/api/orders.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (
                            element not in relationships
                            and data[element] != getattr(order, element, None)
                            and element not in get_updatable_fields()
                        ):
Severity: Major
Found in app/api/orders.py - About 45 mins to fix

Consider simplifying this complex logical expression.
Open

    if data.get('is_billing_enabled') and not (
        data.get('company')
        and data.get('address')
        and data.get('city')
        and data.get('zipcode')
Severity: Major
Found in app/api/orders.py - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

    if mode == 'stripe':
        return (
            (order.paid_via == 'stripe')
            and order.brand
            and order.transaction_id
Severity: Major
Found in app/api/orders.py - About 40 mins to fix

Function check_event_user_ticket_holders has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
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(
Severity: Minor
Found in app/api/orders.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

There are no issues that match your filters.

Category
Status