fossasia/open-event-orga-server

View on GitHub
app/api/events.py

Summary

Maintainability
F
3 days
Test Coverage

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 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

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

Function validate_date has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def validate_date(event, data):
    if event:
        if 'starts_at' not in data:
            data['starts_at'] = event.starts_at

Severity: Minor
Found in app/api/events.py - About 55 mins 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 set_event_id has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def set_event_id(model, identifier, kwargs, attr='event_id', column_name='id'):
Severity: Minor
Found in app/api/events.py - About 35 mins to fix

Function get_chat_token has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def get_chat_token(event_id: int):
    event = Event.query.get_or_404(event_id)

    if not VideoStream(event_id=event.id).user_can_access:
        raise NotFoundError({'source': ''}, 'Video Stream Not Found')
Severity: Minor
Found in app/api/events.py - About 35 mins 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_virtual_room_chat_token has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_virtual_room_chat_token(event_id: int, video_stream_id: int):
    """
    Get room chat token for specific room
    @param event_id: event identifier
    @param video_stream_id: microlocation id
Severity: Minor
Found in app/api/events.py - About 25 mins 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_room_chat_token has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_room_chat_token(event_id: int, microlocation_id: int):
    """
    Get room chat token for specific room
    @param event_id: event identifier
    @param microlocation_id: microlocation id
Severity: Minor
Found in app/api/events.py - About 25 mins 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