fossasia/open-event-orga-server

View on GitHub
app/api/video_stream.py

Summary

Maintainability
C
1 day
Test Coverage

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

    def after_update_object(self, stream, data, view_kwargs):
        if stream.channel and stream.channel.provider == 'bbb':
            bbb_options = stream.extra.get('bbb_options')
            if bbb_options and bbb_options.get('endCurrentMeeting'):
                params_isMeetingRunning = dict(
Severity: Minor
Found in app/api/video_stream.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 join_stream has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def join_stream(stream_id: int):
    stream = VideoStream.query.get_or_404(stream_id)
    if not stream.user_can_access:
        raise NotFoundError({'source': ''}, 'Video Stream Not Found')
    if not stream.channel or stream.channel.provider != 'bbb':
Severity: Minor
Found in app/api/video_stream.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 check_extra has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def check_extra(obj, data):
        if not data.get('extra'):
            return
        channel_id = data.get('channel') or obj.channel_id
        if not channel_id:
Severity: Minor
Found in app/api/video_stream.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 after_create_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def after_create_object(self, stream, data, view_kwargs):
        if stream.channel and stream.channel.provider == 'bbb':
            params_isMeetingRunning = dict(
                meetingID=stream.extra['response']['meetingID'],
            )
Severity: Minor
Found in app/api/video_stream.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_chat_token has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_chat_token(stream_id: int):
    stream = VideoStream.query.get_or_404(stream_id)
    event = stream.event
    if not stream.user_can_access:
        raise NotFoundError({'source': ''}, 'Video Stream Not Found')
Severity: Minor
Found in app/api/video_stream.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