mrDoctorWho/vk4xmpp

View on GitHub

Showing 227 of 283 total issues

Function getFeatures has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def getFeatures(destination, source, ns, disco=False):
    if destination == TransportID:
        features = TransportFeatures
    else:
        features = UserFeatures
Severity: Minor
Found in modules/mod_iq_disco.py - About 35 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

Function __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, source, user=True):
        """
        Uses GLOBAL_USER_SETTINGS variable as default user's settings
        and updates it using settings read from the file
        """
Severity: Minor
Found in library/settings.py - About 35 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

Function getUserData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def getUserData(self, uid, fields=None):
        """
        Gets user data. Such as name, photo, etc
        Args:
            uid: the user id (list or str)
Severity: Minor
Found in gateway.py - About 35 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

Avoid too many return statements within this function.
Open

            return self.connected
Severity: Major
Found in library/xmpp/client.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return self.connected
    Severity: Major
    Found in library/xmpp/client.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return "ok"
      Severity: Major
      Found in library/xmpp/transports.py - About 30 mins to fix

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

            def WaitForResponse(self, ID, timeout=DefaultTimeout):
                """
                Block and wait until stanza with specific "id" attribute will come.
                If no such stanza is arrived within timeout, return None.
                If operation failed for some reason then owner's attributes
        Severity: Minor
        Found in library/xmpp/dispatcher.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

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

            def StreamOpenHandler(self, conn, stanza):
                """
                Handles opening of new incoming stream. Used internally.
                """
                err = None
        Severity: Minor
        Found in library/xmpp/filetransfer.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

        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

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

        def alive_keeper():
            logger.debug("alive_keeper has started!")
        
            def alive_keeper_answer(cl, stanza):
                logger.debug("alive_keeper: answer received, continuing iteration")
        Severity: Minor
        Found in extensions/alive_keeper.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

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

            def endtag(self, tag):
                """
                XML Parser callback. Used internally.
                """
                self.DEBUG(DBG_NODEBUILDER, "DEPTH -> %i , tag -> %s" % (self.__depth, tag), "up")
        Severity: Minor
        Found in library/xmpp/simplexml.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

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

            def _validate_flag(self, flags):
                """
                Verify that flag is defined.
                """
                if flags:
        Severity: Minor
        Found in library/xmpp/debug.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

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

            def getError(self):
                """
                Return the error-condition (if present) or the textual description of the error (otherwise).
                """
                errtag = self.getTag("error")
        Severity: Minor
        Found in library/xmpp/protocol.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

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

        def handleQueue():
            while ALIVE:
                if Queue:
                    user = Queue.pop()
                    user.hashes = Avatars.makeHashes(user)
        Severity: Minor
        Found in extensions/avatar_hash.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

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

            def _muc_getSubTagDataAttr(self, tag, attr):
                for xtag in self.getTags("x", namespace=NS_MUC_USER):
                    for child in xtag.getTags("item"):
                        for cchild in child.getTags(tag):
                            return cchild.getData(), cchild.getAttr(attr)
        Severity: Minor
        Found in library/xmpp/protocol.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

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

            def PlugIn(self, owner):
                """
                Attach to main instance and register ourself and all our staff in it.
                """
                self._owner = owner
        Severity: Minor
        Found in library/xmpp/plugin.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

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

            def PlugIn(self, owner, now=0):
                """
                If the 'now' argument is true then starts using encryption immidiatedly.
                If 'now' in false then starts encryption as soon as TLS feature is
                declared by the server (if it were already declared - it is ok).
        Severity: Minor
        Found in library/xmpp/transports.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

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

            def is_active(self, flag):
                if not self.active:
                    return 0
                if not flag or flag in self.active and DBG_ALWAYS not in self.active or flag not in self.active and DBG_ALWAYS in self.active:
                    return 1
        Severity: Minor
        Found in library/xmpp/debug.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

        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
        Severity: Minor
        Found in extensions/groupchats.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

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

            def checkRosterx(cls, user, resource):
                """
                Checks if the client supports XEP-0144: Roster Item Exchange
                If it doesn't, or it didn't answer us, then transport will use the old method
                """
        Severity: Minor
        Found in library/rostermanager.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

        Severity
        Category
        Status
        Source
        Language