fossasia/open-event-orga-server

View on GitHub
app/api/custom/orders.py

Summary

Maintainability
C
1 day
Test Coverage

Function create_order has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

def create_order():
    data, errors = OrderAmountInputSchema().load(request.get_json())
    if errors:
        return make_response(jsonify(errors), 422)

Severity: Minor
Found in app/api/custom/orders.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

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

import os
from datetime import datetime

from flask import Blueprint, jsonify, make_response, request
from flask.helpers import send_from_directory
Severity: Minor
Found in app/api/custom/orders.py - About 2 hrs to fix

Function ticket_attendee_authorized has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def ticket_attendee_authorized(order_identifier):
    if current_user:
        try:
            order = Order.query.filter_by(identifier=order_identifier).first()
        except NoResultFound:
Severity: Minor
Found in app/api/custom/orders.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

There are no issues that match your filters.

Category
Status