fossasia/open-event-orga-server

View on GitHub
app/api/chat/rocket_chat.py

Summary

Maintainability
C
1 day
Test Coverage

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

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

    def create_room(self, event: Event, microlocation: Optional[Microlocation], data):
        bot_token = data['token']
        bot_id = data['res']['data']['userId']
        if microlocation:
            chat_room_name = microlocation.chat_room_name
Severity: Minor
Found in app/api/chat/rocket_chat.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 register has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

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

    def create_room_virtual_room(
        self, event: Event, videoStream: Optional[VideoStream], data
    ):
        bot_token = data['token']
        bot_id = data['res']['data']['userId']
Severity: Minor
Found in app/api/chat/rocket_chat.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 add_in_room_virtual_room has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def add_in_room_virtual_room(
        self, event: Event, rocket_user_id, videoStream: Optional[VideoStream] = None
    ):
        bot = self.check_or_create_bot()
        data = self.get_token_virtual_room(bot, videoStream=videoStream)
Severity: Minor
Found in app/api/chat/rocket_chat.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 add_in_room has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def add_in_room(
        self, event: Event, rocket_user_id, microlocation: Optional[Microlocation] = None
    ):
        bot = self.check_or_create_bot()
        data = self.get_token(bot)
Severity: Minor
Found in app/api/chat/rocket_chat.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