modules/mod_msg_main.py
Function message_handler
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
Open
def message_handler(cl, msg):
body = msg.getBody()
jidTo = msg.getTo()
destination = jidTo.getStripped()
jidFrom = msg.getFrom()
- 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
Open
if text == "!captcha" and args:
acceptCaptcha(args, source, jidTo)
answer = reportReceived(msg, jidFrom, jidTo)
Avoid deeply nested control flow statements. Open
Open
if user.sendMessage(body, uID, mid=mid):
# check if the client requested the message to be marked as received
if msg.getTag("request", namespace=xmpp.NS_RECEIPTS):
answer = reportReceived(msg, jidFrom, jidTo)
if answer:
Function acceptCaptcha
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def acceptCaptcha(key, source, destination):
"""
Accepts the captcha value in 2 possible ways:
1. User sent a message
2. User sent an IQ with the captcha 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"