Showing 809 of 809 total issues
Function requires_auth
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def requires_auth(f):
@wraps(f)
def decorated(*args, **kwargs):
state = is_authorized()
- Read upRead up
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 banned_users
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def banned_users():
bans = user_manager.get_banned_users()
result = {'global': list(), 'channel': list(), 'room': list()}
channel_bans = bans['channels']
- Read upRead up
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 emit_join_event
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def emit_join_event(activity, user_id, user_name, image) -> None:
# no need if it's wio and autojoin
if environ.env.node == 'wio' and is_autojoin(activity):
return
- Read upRead up
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 remove_room
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def remove_room(channel_id, room_id, user_id, user_name, room_name, is_delayed_removal: bool = False):
if is_delayed_removal:
users_in_room = get_users_in_room(room_id, skip_cache=True)
if len(users_in_room) > 0:
logger.info('ignoring delayed room removal, room {} ({}) is not empty anymore'.format(room_id, room_name))
- Read upRead up
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 autojoin_rooms
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def autojoin_rooms(arg: tuple) -> None:
data, activity = arg
if not str(environ.env.config.get(ConfigKeys.AUTOJOIN_ENABLED, 'false')).lower() in {'true', 'yes', '1', 'y'}:
return
- Read upRead up
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, room_name: str, room_id: str, channel_id: str, user_id: str, user_name: str, ephemeral: bool=True, sort_order: int=False) -> None:
if self.env.cache.get_channel_exists(channel_id) is None:
if not self.channel_exists(channel_id):
raise NoSuchChannelException(channel_id)
- Read upRead up
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 _mark_as_status
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _mark_as_status(self, message_ids: set, receiver_id: str, target_id: str, status: int):
current_acks = self._get_acks_for(message_ids, receiver_id)
to_update = list()
to_add = list()
- Read upRead up
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_channel_acl
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_channel_acl(channel_uuid: str):
form = request.get_json()
action = form['action']
acl_type = form['type']
acl_value = form['value']
- Read upRead up
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_user_invisible
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def set_user_invisible(self, user_id: str, is_offline=False) -> None:
# TODO: send to "status" topic that the user changed status
if is_offline:
self.env.cache.set_user_status_invisible(user_id)
- Read upRead up
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_sids_for_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_sids_for_user(self, user_id: str) -> list:
@with_session
def get_sids(session=None) -> Union[list, None]:
user_sids = session.query(Sids)\
.filter(Sids.user_uuid == user_id)\
- Read upRead up
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 do_post
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def do_post(self):
is_valid, msg, json = self.validate_json()
if not is_valid:
logger.error('invalid json: %s' % msg)
raise RuntimeError('invalid json')
- Read upRead up
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_app
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_app():
_app = Flask(__name__)
# used for encrypting cookies for handling sessions
_app.config['SECRET_KEY'] = environ.env.config.get(ConfigKeys.SERVICE_SECRET, default='')
- Read upRead up
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_channels_with_sort
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_channels_with_sort(self):
key = RedisKeys.channels_with_sort()
channels = self.cache.get(key)
if channels is not None:
return channels
- Read upRead up
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 _format_user_roles
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _format_user_roles(self, g_roles, c_roles, r_roles) -> dict:
_output = {
'global': list(),
'channel': dict(),
'room': dict()
- Read upRead up
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_users_roles
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_users_roles(self, user_ids: list, session=None) -> None:
g_roles = session.query(GlobalRoles).all()
c_roles = session.query(ChannelRoles).join(ChannelRoles.channel).all()
r_roles = session.query(RoomRoles).join(RoomRoles.room).all()
- Read upRead up
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_avatars_for
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_avatars_for(self, user_ids: set) -> dict:
@with_session
def _get_user_info(_user_id, session=None) -> UserInfo:
return session.query(UserInfo).filter(UserInfo.user_id == _user_id).first()
- Read upRead up
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 on_login
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_login(self, activity: Activity) -> (bool, int, str):
user_id = activity.actor.id
is_banned, duration = utils.is_banned_globally(user_id)
if is_banned:
- Read upRead up
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_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _validate_params(self):
is_valid, msg, json_data = self.validate_json(self.request, silent=False)
if not is_valid:
raise RuntimeError('invalid json: %s' % msg)
- Read upRead up
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 do_post
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def do_post(self):
is_valid, msg, json = self.validate_json()
if not is_valid:
logger.error('invalid json: %s' % msg)
raise RuntimeError('invalid json')
- Read upRead up
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_session
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_session(self, session: dict) -> (bool, str):
"""
validate that all required parameters were send from the client side
:param session: the session dict to validate
- Read upRead up
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"