File groupchats.py
has 493 lines of code (exceeds 250 allowed). Consider refactoring. Open
# coding: utf-8
# This file is a part of VK4XMPP transport
# © simpleApps, 2013 — 2018.
# Installation:
Function handleOutgoingChatMessage
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def handleOutgoingChatMessage(user, vkChat):
"""
Handles outging VK messages and sends them to XMPP
"""
# peer_id for newer APIs
- 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 exterminateChats
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def exterminateChats(user=None, chats=[]):
"""
Calls a Dalek for exterminate the chat
The chats argument must be a list of tuples
"""
- 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 update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update(self, userObject):
"""
Updates chat users and sends messages
Uses two user lists to prevent losing of any of 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 handleMessage
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def handleMessage(self, user, vkChat, retry=True):
"""
Handle incoming (VK -> XMPP) messages
"""
if self.created:
- 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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def init(self, owner, id, jid, subject, date, users=[]):
Function setChatConfig
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def setChatConfig(chat, jidFrom, exterminate=False, cb=None, args={}):
Function setAffiliation
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def setAffiliation(chat, afl, jid, jidFrom=TransportID, reason=None):
Function chatMessage
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def chatMessage(chat, text, jidFrom, subj=None, timestamp=0):
Function cleanTheChatsUp
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def cleanTheChatsUp():
"""
Calls Dalek(s) to exterminate inactive users or their chats, whatever they catch
"""
chats = runDatabaseQuery("select jid, owner, last_used, user from groupchats")
- 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 getUserObject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def getUserObject(source):
"""
Gets user object by chat jid
"""
user = 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"
Further reading
Function getUserByID
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def getUserByID(id):
for user in Users.values():
if hasattr(user, "vk"):
if user.vk.getUserPreferences()[0] == id:
return user
- 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"