fossasia/open-event-orga-server

View on GitHub

Showing 300 of 1,194 total issues

File routes.py has 2070 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from app.api.access_codes import (
    AccessCodeDetail,
    AccessCodeList,
    AccessCodeListPost,
    AccessCodeRelationshipOptional,
Severity: Major
Found in app/api/routes.py - About 5 days to fix

File tasks.py has 834 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import base64
import csv
import logging
import os
import urllib.error
Severity: Major
Found in app/api/helpers/tasks.py - About 2 days to fix

Function permission_manager has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
Open

def permission_manager(view, view_args, view_kwargs, *args, **kwargs):
    """The function use to check permissions

    :param callable view: the view
    :param list view_args: view args
Severity: Minor
Found in app/api/helpers/permission_manager.py - About 1 day 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 760 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import logging
import time

import omise
Severity: Major
Found in app/api/orders.py - About 1 day to fix

File mail.py has 746 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import base64
import datetime
import logging
import os
from itertools import groupby
Severity: Major
Found in app/api/helpers/mail.py - About 1 day to fix

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

    def before_update_object(self, order, data, view_kwargs):
        """
        before update object method of order details
        1. admin can update all the fields.
        2. event organizer
Severity: Minor
Found in app/api/orders.py - About 1 day 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 events.py has 725 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from datetime import datetime

import pytz
from flask import g, request
from flask.blueprints import Blueprint
Severity: Major
Found in app/api/events.py - About 1 day to fix

Function export_orders_csv has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
Open

def export_orders_csv(orders):
    headers = [
        'Order#',
        'Order Date',
        'Status',
Severity: Minor
Found in app/api/helpers/csv_jobs_util.py - About 1 day 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_object has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    def before_get_object(self, view_kwargs):
        """
        before get method for user object
        :param view_kwargs:
        :return:
Severity: Minor
Found in app/api/users.py - About 1 day 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 static.py has 563 lines of code (exceeds 250 allowed). Consider refactoring.
Open

##
# Module for helper static variables
##

# Event Licences
Severity: Major
Found in app/api/helpers/static.py - About 1 day to fix

File events.py has 507 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import pytz
from flask_rest_jsonapi.exceptions import ObjectNotFound
from marshmallow import validate, validates_schema
from marshmallow.schema import Schema
from marshmallow_jsonapi import fields
Severity: Major
Found in app/api/schema/events.py - About 1 day to fix

Function export_sessions_csv has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

def export_sessions_csv(sessions):
    headers = [
        'Session Title',
        'Session Starts At',
        'Session Ends At',
Severity: Minor
Found in app/api/helpers/csv_jobs_util.py - About 7 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 event.py has 483 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import re
from argparse import Namespace
from datetime import datetime

import flask_login as login
Severity: Minor
Found in app/models/event.py - About 7 hrs to fix

File discount_codes.py has 460 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from datetime import datetime

from flask_jwt_extended import current_user
from flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship
from flask_rest_jsonapi.exceptions import ObjectNotFound
Severity: Minor
Found in app/api/discount_codes.py - About 7 hrs to fix

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

    def before_get(self, args, kwargs):
        if kwargs.get('ticket_id'):
            if has_access('is_coorganizer'):
                ticket = safe_query_kwargs(Ticket, kwargs, 'ticket_id')
                if ticket.discount_code_id:
Severity: Minor
Found in app/api/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

User has 48 functions (exceeds 20 allowed). Consider refactoring.
Open

class User(SoftDeletionModel):
    """User model class"""

    __tablename__ = 'users'

Severity: Minor
Found in app/models/user.py - About 6 hrs to fix

Function query has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    def query(self, view_kwargs):
        """
        query method for EventList class
        :param view_kwargs:
        :return:
Severity: Minor
Found in app/api/events.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 permission_manager.py has 432 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from typing import Union

from flask import request
from flask_jwt_extended import current_user, verify_jwt_in_request
Severity: Minor
Found in app/api/helpers/permission_manager.py - About 6 hrs to fix

Function export_speakers_csv has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

def export_speakers_csv(speakers):
    headers = [
        'Speaker Name',
        'Speaker Email',
        'Speaker Session(s)',
Severity: Minor
Found in app/api/helpers/csv_jobs_util.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 auth.py has 424 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import base64
import logging
import random
import string
from datetime import timedelta
Severity: Minor
Found in app/api/auth.py - About 6 hrs to fix
Severity
Category
Status
Source
Language