Showing 480 of 808 total issues
Function get_channels
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_channels(self) -> dict:
@with_session
def _get_channels(session=None):
rows = session.query(Channels).all()
_channels = 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_all_permanent_rooms
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_all_permanent_rooms(self):
@with_session
def _get_all_permanent_rooms(session=None):
rooms = session.query(Rooms).filter(Rooms.ephemeral.is_(False)).all()
if rooms is None or len(rooms) == 0:
- 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 save_spam_prediction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def save_spam_prediction(self, activity: Activity, message, y_hats: tuple, session=None):
to_name = activity.target.display_name
from_name = activity.actor.display_name
if is_base64(to_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 _get_rooms_for_channel_without_info
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_rooms_for_channel_without_info(self, channel_id: str) -> dict:
"""
room.uuid: {
'ephemeral': room.ephemeral,
'name': 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 db_connect
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def db_connect(self):
"""
Performs database connection using database settings from settings.py.
Returns sqlalchemy engine instance
"""
- 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_with_role
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_users_with_role(self, roles, role_key):
if roles is None or len(roles) == 0:
return dict()
found = 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 is_banned_globally
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def is_banned_globally(self, user_id: str) -> (bool, Union[str, None]):
now = datetime.utcnow()
duration, time, username = self.env.cache.get_global_ban_timestamp(user_id)
if time is not None and len(time.strip()) != 0:
time = datetime.fromtimestamp(float(time))
- 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 rename_room
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def rename_room(self, channel_id: str, room_id: str, room_name: str) -> 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 cleanup
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cleanup(self):
"""
avoid in-memory cache buildup, since keys are only deleted if
the expiry time has passed when accessing them
"""
- 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 __init__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, env, is_external_queue: bool):
super().__init__(env, is_external_queue, queue_type='amqp', logger=logger)
conf = env.config
queue_host = conf.get(ConfigKeys.HOST, domain=self.domain_key, 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 on_invite
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def on_invite(self, activity: Activity) -> (bool, int, str):
if not hasattr(activity.actor, 'url'):
return False, ECodes.MISSING_ACTOR_URL, 'need invite room uuid in actor.url'
invite_room = activity.actor.url
- 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_or_rename_room
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _remove_or_rename_room(self, activity: Activity, action: str) -> (bool, int, str):
user_id = activity.actor.id
room_id = activity.target.id
if utils.is_owner(room_id, 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 __init__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, ban_duration):
if ban_duration is None or ban_duration == '':
raise ValueError('empty ban duration')
valid_ends = {'s', 'm', 'h', 'd'}
- 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_kick
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def on_kick(self, activity: Activity) -> (bool, int, str):
kicker_id = activity.actor.id
room_id = activity.target.id
user_id_to_kick = activity.object.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_room_id_for_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_room_id_for_name(self, room_name: str, use_default_channel: bool = False) -> str:
@with_session
def _do_get(session=None):
return session.query(Rooms)\
.filter(Rooms.name == 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 _format_acls
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _format_acls(self, all_acls: dict, encode_result: bool = True) -> list:
output = list()
for action, acls in all_acls.items():
for acl_type, acl_value in acls.items():
output.append({
- 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 publish
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def publish(self, message: dict) -> None:
n_tries = 3
current_try = 0
failed = False
- 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 online_count
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def online_count():
c = statsd.StatsClient(STATSD_HOST, 8125, prefix=PREFIX + 'online')
while True:
for _, _, community, db_num in hosts:
count = r_servers[community].scard('users:multicast')
- 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 _setup_external_queue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _setup_external_queue(self, conf, env):
ext_queue_type = conf.get(ConfigKeys.TYPE, domain=ConfigKeys.EXTERNAL_QUEUE)
if ext_queue_type is None:
# external queue not required
self.env.external_publisher = PubSub.mock_publish
- 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 __init__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, env, is_external_queue: bool):
super().__init__(env, is_external_queue, queue_type='kafka', logger=logger)
eq_host = env.config.get(ConfigKeys.HOST, domain=self.domain_key, default=None)
eq_queue = env.config.get(ConfigKeys.QUEUE, domain=self.domain_key, default=None)
- 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"