Showing 227 of 283 total issues
Function asDict
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def asDict(self):
"""
Represent dataform as simple dictionary mapping of datafield names to their values.
"""
ret = {}
- 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 RegisterHandler
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def RegisterHandler(self, name, handler, typ="", ns="", xmlns=None, makefirst=0, system=0):
"""Register user callback as stanzas handler of declared type. Callback must take
(if chained, see later) arguments: dispatcher instance (for replying), incomed
return of previous handlers.
The callback must raise xmpp.NodeProcessed just before return if it want preven
- 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 UnregisterHandler
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def UnregisterHandler(self, name, handler, typ="", ns="", xmlns=None):
"""
Unregister handler. "typ" and "ns" must be specified exactly the same as with registering.
"""
if not xmlns:
- 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
Avoid deeply nested control flow statements. Open
if found:
break
Avoid deeply nested control flow statements. Open
for key in dictForm.keys():
if key in config:
config[key] = utils.normalizeValue(dictForm[key])
note = "The settings were changed."
Avoid deeply nested control flow statements. Open
if name in STAT_FIELDS:
attr = STAT_FIELDS[name]
value = stats[attr].pop(0)
node = xmpp.Node("stat", {"units": attr})
node.setAttr("name", name)
Avoid deeply nested control flow statements. Open
if chats:
_fields = dictToDataForm(dict([(chat[0], False) for chat in chats]))
simpleForm = buildForm(simpleForm, fields=_fields, title="Delete chats")
else:
note = "Nothing to delete"
Avoid deeply nested control flow statements. Open
with user.sync:
user.vk.sendMessage(body, chatId, "chat_id")
if chat.isUpdateRequired():
Avoid deeply nested control flow statements. Open
if "&" in token or "=" in token:
match = api.token_exp.search(token)
if match:
token = match.group(1)
# get rid of unnecessary data (if present)
Avoid deeply nested control flow statements. Open
if not form:
simpleForm = buildForm(simpleForm,
fields=[{"var": "token", "type": "text-single", "label": "API Token"}],
title=_("Enter the API token"))
else:
Avoid deeply nested control flow statements. Open
if not form:
_fields = dictToDataForm(dict([(mod, mod in Manager.loaded) for mod in modules]))
simpleForm = buildForm(simpleForm, fields=_fields, title="(Re)load modules",
data=[_("Modules can be loaded or reloaded if they already loaded")])
Function handleUser
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def handleUser(cls, user):
"""
Tries to reinitialize poll for LONGPOLL_RETRY_COUNT every LONGPOLL_RETRY_TIMEOUT seconds
As soon as poll is initialized the user will be removed from buffer
Args:
- 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
Avoid deeply nested control flow statements. Open
if not form:
simpleForm = buildForm(simpleForm,
fields=[
{"var": "subject", "type": "text-single", "label": _("Subject"), "value": "Announcement"},
{"var": "body", "type": "text-multi", "label": _("Message"), "required": True},
Function sendInitPresence
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def sendInitPresence(self):
"""
Sends available presence to the user from all online friends
"""
if not self.vk.engine.captcha:
- 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
Avoid deeply nested control flow statements. Open
if not attachments and not chat:
message = [{"out": 0, "from_id": uid, "id": mid, "date": date, "text": body}]
# we substract 1 from msg id b/c VK now has reverse history so we need to ask what happened before this exact message
utils.runThread(user.sendMessages, (False, message, mid - 1, uid), "sendMessages-%s" % user.source)
Avoid deeply nested control flow statements. Open
if not form:
simpleForm = buildForm(simpleForm,
fields=[{"var": "jids", "type": "jid-multi", "label": _("Jabber ID's"), "required": True}])
else:
if dictForm.get("jids"):
Avoid deeply nested control flow statements. Open
if user.friends[id]["online"]:
sendPresence(source, destination, hash=USER_CAPS_HASH)
if destination == TransportID:
Avoid deeply nested control flow statements. Open
if jid != TransportID:
runDatabaseQuery("update groupchats set owner=? where jid=?", (source, jid), set=True)
Avoid deeply nested control flow statements. Open
if not phone or phone == "+":
result = utils.buildIQError(iq, xmpp.ERR_BAD_REQUEST, _("Phone is incorrect."))
else:
Avoid deeply nested control flow statements. Open
if status == MSG_SKIP:
for func in iter_:
utils.execute(func, (self, message))
break
elif status == MSG_APPEND: