fossasia/open-event-orga-server

View on GitHub

Showing 300 of 1,194 total issues

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

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

    def get_token(
        self,
        user: User,
        event: Optional[Event] = None,
        retried=False,
Severity: Minor
Found in app/api/chat/rocket_chat.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 get_token_virtual_room has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def get_token_virtual_room(
        self,
        user: User,
        event: Optional[Event] = None,
        retried=False,
Severity: Minor
Found in app/api/chat/rocket_chat.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 _fix_related_fields has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def _fix_related_fields(srv, data, service_ids):
    """
    Fixes the ids services which are related to others.
    Like track, format -> session
    Also fixes their schema
Severity: Minor
Found in app/api/helpers/import_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 get_value_from_qr_filed has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def get_value_from_qr_filed(field: BadgeFieldForms, ticket_holder: TicketHolder) -> dict:
    """Get the value of a QR code field."""
    qr_value = {}
    custom_fields = []
    if field.qr_custom_field is not None:
Severity: Minor
Found in app/api/helpers/badge_forms.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 upgrade has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.rename_table('user', 'temp_user')
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False, autoincrement=True),
Severity: Major
Found in migrations/versions/9105f9e64cdc_.py - About 2 hrs to fix

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

File speaker_invites.py has 264 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from flask import Blueprint, jsonify
from flask_jwt_extended import current_user
from flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship
from sqlalchemy.orm.exc import NoResultFound

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

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

def export_attendees_csv_task(self, event_id):
    attendees = (
        db.session.query(TicketHolder)
        .filter_by(event_id=event_id)
        .order_by(desc(func.date(TicketHolder.created_at)))
Severity: Minor
Found in app/api/helpers/tasks.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 upgrade has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_or_replace_sp(replace_in_table)
    op.alter_column('social_links', 'link',
                    existing_type=sa.VARCHAR(),
Severity: Major
Found in migrations/versions/1b9c8698c632_.py - About 2 hrs to fix

Function downgrade has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def downgrade():
    # commands auto generated by Alembic - please adjust! #
    op.rename_table('activities', 'activity')
    op.rename_table('custom_placeholders', 'custom_placeholder')
    op.rename_table('custom_sys_roles', 'custom_sys_role')
Severity: Major
Found in migrations/versions/a1c17effff1d_.py - About 2 hrs to fix

Function upgrade has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def upgrade():
    # commands auto generated by Alembic - please adjust! #
    op.rename_table('activity', 'activities')
    op.rename_table('custom_placeholder', 'custom_placeholders')
    op.rename_table('custom_sys_role', 'custom_sys_roles')
Severity: Major
Found in migrations/versions/a1c17effff1d_.py - About 2 hrs to fix

Function before_patch has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def before_patch(_args, kwargs, data):
        """
        before patch method
        :param _args:
        :param kwargs:
Severity: Minor
Found in app/api/custom_forms.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 before_patch has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def before_patch(_args, kwargs, data):
        """
        before patch method
        :param _args:
        :param kwargs:
Severity: Minor
Found in app/api/badge_forms.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 create_object has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def create_object(self, data, view_kwargs):
        """
        create_object method for the Charges layer
        charge the user using paypal or stripe
        :param data:
Severity: Minor
Found in app/api/data_layers/ChargesLayer.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 instance.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import os.path
import secrets
import sys
from datetime import timedelta
Severity: Minor
Found in app/instance.py - About 2 hrs to fix

Function create_default_user has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def create_default_user(email, password):
    print("Your login is 'super_admin'.")
    if not email:
        ask_email = True
        while ask_email:
Severity: Minor
Found in create_db.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 login_user has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def login_user(provider):
    if provider == 'facebook':
        provider_class = FbOAuth()
        payload = {
            'client_id': provider_class.get_client_id(),
Severity: Minor
Found in app/api/auth.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 upgrade has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.execute("SET TIME ZONE 'utc'")
    op.alter_column('access_codes', 'created_at',
                    existing_type=postgresql.TIMESTAMP(),
Severity: Minor
Found in migrations/versions/f5fec4ca8b2b_.py - About 1 hr to fix
Severity
Category
Status
Source
Language