fossasia/open-event-orga-server

View on GitHub
app/api/helpers/order.py

Summary

Maintainability
D
1 day
Test Coverage

File order.py has 421 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from datetime import datetime, timedelta, timezone

from flask import render_template
from flask_rest_jsonapi.exceptions import ObjectNotFound
Severity: Minor
Found in app/api/helpers/order.py - About 6 hrs to fix

Function calculate_order_amount has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

def calculate_order_amount(tickets, verify_discount=True, discount_code=None):
    from app.api.helpers.ticketing import (
        is_discount_available,
        validate_discount_code,
        validate_tickets,
Severity: Minor
Found in app/api/helpers/order.py - About 4 hrs 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 create_onsite_attendees_for_order has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def create_onsite_attendees_for_order(data):
    """
    Creates on site ticket holders for an order and adds it into the request data.
    :param data: data initially passed in the POST request for order.
    :return:
Severity: Minor
Found in app/api/helpers/order.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 get_discount_amount has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def get_discount_amount(code, price, tax_included, tax, ticket_tax, discounted_tax):
Severity: Minor
Found in app/api/helpers/order.py - About 45 mins to fix

Function get_discount_data has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def get_discount_data(
Severity: Minor
Found in app/api/helpers/order.py - About 45 mins to fix

Function create_pdf_tickets_for_holder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def create_pdf_tickets_for_holder(order):
    """
    Create tickets and invoices for the holders of an order.
    :param order: The order for which to create tickets for.
    """
Severity: Minor
Found in app/api/helpers/order.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