mrDoctorWho/vk4xmpp

View on GitHub
extensions/status.py

Summary

Maintainability
C
7 hrs
Test Coverage

Function statustovk_prs01 has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

def statustovk_prs01(source, prs, retry=3):
    if source in Users and prs.getType() in ("available", None):
        if prs.getTo() == TransportID:
            user = Users[source]
            if user.settings.status_to_vk:
Severity: Minor
Found in extensions/status.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 not getattr(user, "last_status", None) or user.last_status != status:
                        if mask & 1024 == 1024:
                            if not status:
                                user.vk.method("status.set", {"text": ""})
                            else:
Severity: Major
Found in extensions/status.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if retry:
                            utils.runThread(statustovk_prs01, (source, prs, (retry -1)), delay=10)
    
    
    Severity: Major
    Found in extensions/status.py - About 45 mins to fix

      Function statusfromvk_prs02 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def statusfromvk_prs02(prs, destination, source):
          if source != TransportID and destination in Users:
              user = Users[destination]
              if user.settings.status_from_vk and not prs.getType():
                  id = vk2xmpp(source)
      Severity: Minor
      Found in extensions/status.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