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
- Create a ticketCreate a ticket
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,
- 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_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:
- 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 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):
- Create a ticketCreate a ticket
Function get_discount_data
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_discount_data(
- Create a ticketCreate a ticket
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.
"""
- 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"