mrDoctorWho/vk4xmpp

View on GitHub
modules/mod_msg_main.py

Summary

Maintainability
C
7 hrs
Test Coverage

Function message_handler has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

def message_handler(cl, msg):
    body = msg.getBody()
    jidTo = msg.getTo()
    destination = jidTo.getStripped()
    jidFrom = msg.getFrom()
Severity: Minor
Found in modules/mod_msg_main.py - About 5 hrs to fix

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 text == "!captcha" and args:
                        acceptCaptcha(args, source, jidTo)
                        answer = reportReceived(msg, jidFrom, jidTo)

Severity: Major
Found in modules/mod_msg_main.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    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:
    Severity: Major
    Found in modules/mod_msg_main.py - About 45 mins to fix

      Function acceptCaptcha has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      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
      Severity: Minor
      Found in modules/mod_msg_main.py - About 25 mins to fix

      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

      There are no issues that match your filters.

      Category
      Status