fossasia/open-event-orga-server

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

Summary

Maintainability
C
1 day
Test Coverage

Function calculate_update_amount has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def calculate_update_amount(order):
        discount = None
        if order.discount_code_id:
            discount = order.discount_code
        # Access code part will be done ticket_holders API
Severity: Minor
Found in app/api/helpers/ticketing.py - About 3 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

File ticketing.py has 265 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from datetime import datetime

import pytz
from flask_rest_jsonapi.exceptions import ObjectNotFound
Severity: Minor
Found in app/api/helpers/ticketing.py - About 2 hrs to fix

Function is_discount_available has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def is_discount_available(
    discount_code,
    tickets=None,
    ticket_holders=None,
    quantity_discount=None,
Severity: Minor
Found in app/api/helpers/ticketing.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 validate_discount_code has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def validate_discount_code(
    discount_code, tickets=None, ticket_holders=None, event_id=None
):
    """Tickets validation should be performed before calling this function"""
    from app.models.discount_code import DiscountCode
Severity: Minor
Found in app/api/helpers/ticketing.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 is_discount_available has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def is_discount_available(
Severity: Minor
Found in app/api/helpers/ticketing.py - About 35 mins to fix

There are no issues that match your filters.

Category
Status