fossasia/open-event-orga-server

View on GitHub

Showing 300 of 1,194 total issues

File payment.py has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json

import omise
import paypalrestsdk
import requests
Severity: Minor
Found in app/api/helpers/payment.py - About 4 hrs to fix

File import_helpers.py has 335 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import os
import shutil
import traceback
import uuid
Severity: Minor
Found in app/api/helpers/import_helpers.py - About 4 hrs to fix

File rocket_chat.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import random
import string
from dataclasses import dataclass
from typing import Optional
Severity: Minor
Found in app/api/chat/rocket_chat.py - About 3 hrs to fix

File system_mails.py has 317 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
All the System mails
Register a mail here before using it
"""

Severity: Minor
Found in app/api/helpers/system_mails.py - About 3 hrs to fix

Function before_get_object has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def before_get_object(self, view_kwargs):
        """
        before get method for Discount Code detail
        :param view_kwargs:
        :return:
Severity: Minor
Found in app/api/discount_codes.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

Function before_get has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def before_get(self, args, kwargs):
        if kwargs.get('video_stream_id'):
            stream = safe_query_kwargs(VideoStream, kwargs, 'video_stream_id', 'id')

            if stream.channel and stream.channel.provider == 'bbb':
Severity: Minor
Found in app/api/video_recordings.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 users.py has 311 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from flask_jwt_extended import current_user
from marshmallow import pre_dump
from marshmallow_jsonapi import fields
from marshmallow_jsonapi.flask import Relationship

Severity: Minor
Found in app/api/schema/users.py - About 3 hrs to fix

Function create_save_image_sizes has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def create_save_image_sizes(
    image_file, image_sizes_type, unique_identifier=None, folder=None
):
    """
    Save the resized version of the background image
Severity: Minor
Found in app/api/helpers/files.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

Function to_ical has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def to_ical(event, include_sessions=False, my_schedule=False, user_id=None):
    cal = Calendar()
    cal.add('version', '2.0')
    cal.add('METHOD', 'PUBLISH')
    cal.add('X-WR-CALNAME', event.name)
Severity: Minor
Found in app/api/helpers/calendar/ical.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

Function validate_custom_form_constraints has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def validate_custom_form_constraints(form, obj, excluded):
    """
    The validate custom form constraints.
    """
    conditions = {
Severity: Minor
Found in app/api/helpers/custom_forms.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

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

    def before_update_object(self, event, data, view_kwargs):
        """
        method to save image urls before updating event object
        :param event:
        :param data:
Severity: Minor
Found in app/api/events.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 scheduled_jobs.py has 302 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime
import logging

import pytz
from flask_celeryext import RequestContextTask
Severity: Minor
Found in app/api/helpers/scheduled_jobs.py - About 3 hrs to fix

File export_helpers.py has 296 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import os
import shutil
from collections import OrderedDict
from datetime import datetime
Severity: Minor
Found in app/api/helpers/export_helpers.py - About 3 hrs to fix

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 tickets.py has 292 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from flask import Blueprint, jsonify
from flask_jwt_extended import current_user, verify_jwt_in_request
from flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship
from flask_rest_jsonapi.exceptions import ObjectNotFound
from sqlalchemy.orm.exc import NoResultFound
Severity: Minor
Found in app/api/tickets.py - About 3 hrs to fix

Function _download_media has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

def _download_media(data, srv, dir_path, settings):
    """
    Downloads the media and saves it
    """
    if srv not in DOWNLOAD_FIEDLS:
Severity: Minor
Found in app/api/helpers/export_helpers.py - About 2 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 send_email has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def send_email(to, action, subject, html, attachments=None, bcc=None, reply_to=None):
    """
    Sends email and records it in DB
    """
    from .tasks import get_smtp_config, send_email_task_sendgrid, send_email_task_smtp
Severity: Minor
Found in app/api/helpers/mail.py - About 2 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 validate_satus has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_satus(self, data, original_data):
        if 'role' in data and 'role_name' in data:
            try:
                role = Role.query.filter_by(id=data['role']).one()
            except NoResultFound:
Severity: Minor
Found in app/api/schema/role_invites.py - About 2 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 check_in_stats.py has 268 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime

from flask import Blueprint, request
from sqlalchemy import desc

Severity: Minor
Found in app/api/custom/check_in_stats.py - About 2 hrs to fix

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

    def before_create_object(self, data, view_kwargs):
        if data.get('used_for') == 'ticket' and (event_id := data.get('event')):
            discount_codes = DiscountCode.query.filter_by(
                event_id=event_id, code=data['code'], deleted_at=None
            )
Severity: Minor
Found in app/api/discount_codes.py - About 2 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