fossasia/open-event-orga-server

View on GitHub

Showing 300 of 1,194 total issues

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 validate_value has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_value(self, data, original_data):
        if 'id' in original_data['data']:
            try:
                discount_code = DiscountCode.query.filter_by(
                    id=original_data['data']['id']
Severity: Minor
Found in app/api/schema/discount_codes.py - About 6 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 before_update_object has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def before_update_object(self, obj, data, kwargs):
        """
        before update object method for attendee detail
        :param obj:
        :param data:
Severity: Minor
Found in app/api/attendees.py - About 6 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 csv_jobs_util.py has 394 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import pytz

from app.api.admin_sales.utils import event_type, summary
from app.api.helpers.group_user_role import get_user_group_role
from app.models import db
Severity: Minor
Found in app/api/helpers/csv_jobs_util.py - About 5 hrs to fix

File user.py has 392 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import random
from datetime import datetime

import humanize
import pytz
Severity: Minor
Found in app/models/user.py - About 5 hrs to fix

File users.py has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from datetime import datetime

from flask import Blueprint, abort, jsonify, make_response, request
from flask_jwt_extended import current_user, verify_fresh_jwt_in_request
Severity: Minor
Found in app/api/users.py - About 5 hrs to fix

File sessions.py has 379 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from datetime import datetime
from typing import Dict, Optional

import pytz
from flask import Blueprint, g, jsonify, request
Severity: Minor
Found in app/api/sessions.py - About 5 hrs to fix

File files.py has 374 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import base64
import io
import os
import urllib.parse
import urllib.request
Severity: Minor
Found in app/api/helpers/files.py - About 5 hrs to fix

Function create_print_badge_pdf has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

def create_print_badge_pdf(self, attendee_id, list_field_show):
    """
    Create tickets and invoices for the holders of an order.
    @param self: create_print_badge_pdf
    @param attendee_id: attendee
Severity: Minor
Found in app/api/helpers/tasks.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 populate_db.py has 370 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from app.api.helpers.db import get_or_create

# Admin message settings
from app.api.helpers.system_mails import MailType
from app.instance import current_app
Severity: Minor
Found in populate_db.py - About 4 hrs to fix

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

    def before_update_object(self, user, data, view_kwargs):
        # TODO: Make a celery task for this
        # if data.get('avatar_url') and data['original_image_url'] != user.original_image_url:
        #     try:
        #         uploaded_images = create_save_image_sizes(data['original_image_url'], 'speaker-image', user.id)
Severity: Minor
Found in app/api/users.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_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

Event has 36 functions (exceeds 20 allowed). Consider refactoring.
Open

class Event(SoftDeletionModel):
    """Event object table"""

    class State:
        PUBLISHED = 'published'
Severity: Minor
Found in app/models/event.py - About 4 hrs to fix

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

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

File f5fec4ca8b2b_.py has 357 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""empty message

Revision ID: f5fec4ca8b2b
Revises: b15e124e9b93
Create Date: 2017-06-07 02:26:13.097039
Severity: Minor
Found in migrations/versions/f5fec4ca8b2b_.py - About 4 hrs to fix

Function _upload_media has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

def _upload_media(task_handle, event_id, base_path):
    """
    Actually uploads the resources
    """
    global UPLOAD_QUEUE
Severity: Minor
Found in app/api/helpers/import_helpers.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 export has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def export(event_id):
        """Takes an event id and returns the event in pentabarf XML format"""
        event = EventModel.query.get(event_id)
        diff = event.ends_at - event.starts_at

Severity: Minor
Found in app/api/helpers/pentabarfxml.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 video_stream.py has 350 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from uuid import uuid4

from flask import jsonify
from flask.blueprints import Blueprint
Severity: Minor
Found in app/api/video_stream.py - About 4 hrs to fix

Function before_create_object has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    def before_create_object(self, data, _view_kwargs):
        """
        before create object method for UserCheckInListPost Class
        :param data:
        :param _view_kwargs:
Severity: Minor
Found in app/api/user_check_in.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

Severity
Category
Status
Source
Language