mrDoctorWho/vk4xmpp

View on GitHub

Showing 283 of 283 total issues

Function connect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def connect(self, username=None, password=None, token=None):
        """
        Initializes a VK() object and tries to make an authorization if no token provided
        Args:
            username: the user's phone number or e-mail for password authentication
Severity: Minor
Found in gateway.py - About 1 hr 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 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, name=None, value=None, typ=None, required=0, label=None, desc=None, options=[], node=None):
Severity: Major
Found in library/xmpp/protocol.py - About 1 hr to fix

    Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, typ=None, queryNS=None, attrs={}, to=None, frm=None, payload=[], xmlns=NS_CLIENT, node=None):
    Severity: Major
    Found in library/xmpp/protocol.py - About 1 hr to fix

      Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, active_flags=None, log_file=sys.stderr, prefix="DEBUG: ", sufix="\n", time_stamp=0, flag_show=None, validate_flags=False, welcome=-1):
      Severity: Major
      Found in library/xmpp/debug.py - About 1 hr to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                        for key in attrs.keys():
                            if key not in node.attrs or node.attrs[key] != attrs[key]:
        Severity: Major
        Found in library/xmpp/simplexml.py and 1 other location - About 1 hr to fix
        library/xmpp/simplexml.py on lines 370..371

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 38.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                        for key in attrs.keys():
                            if key not in node.attrs or node.attrs[key] != attrs[key]:
        Severity: Major
        Found in library/xmpp/simplexml.py and 1 other location - About 1 hr to fix
        library/xmpp/simplexml.py on lines 350..351

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 38.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function asDict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def asDict(self):
                """
                Represent dataitem as simple dictionary mapping of datafield names to their values.
                """
                ret = {}
        Severity: Minor
        Found in library/xmpp/protocol.py - About 55 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 _as_one_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _as_one_list(self, items):
                """
                Init param might contain nested lists, typically from group flags.
                This code organises lst and remves dupes.
                """
        Severity: Minor
        Found in library/xmpp/debug.py - About 55 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 Show has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def Show(self, flag, msg, prefix=""):
                msg = msg.replace("\r", "\\r").replace("\n", "\\n").replace("><", ">\n  <")
                if not colors_enabled:
                    pass
                elif prefix in self.colors:
        Severity: Minor
        Found in library/xmpp/debug.py - About 55 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 streamErrorHandler has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def streamErrorHandler(self, conn, error):
                name, text = "error", error.getData()
                for tag in error.getChildren():
                    if tag.getNamespace() == NS_XMPP_STREAMS:
                        if tag.getName() == "text":
        Severity: Minor
        Found in library/xmpp/dispatcher.py - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, name, code=None, typ=None, text=None):
                """
                Create new error node object.
                Mandatory parameter: name - name of error condition.
                Optional parameters: code, typ, text. Used for backwards compartibility with older jabber protocol.
        Severity: Minor
        Found in library/xmpp/protocol.py - About 55 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 dobind has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def dobind(self, sasl):
                # This has to be done before binding, because we can receive a route stanza before binding finishes
                self._route = self.route
                if self.bind:
                    for domain in self.domains:
        Severity: Minor
        Found in library/xmpp/client.py - About 55 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 _getResourceData has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _getResourceData(self, jid, dataname):
                """
                Return specific jid's resource representation in internal format. Used internally.
                """
                if jid.find("/") + 1:
        Severity: Minor
        Found in library/xmpp/roster.py - About 55 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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                if msg.getType() == "groupchat":
                    user = Chat.getUserObject(destination)
                else:
                    user = Users.get(destination)
        Severity: Minor
        Found in extensions/sticker.py and 1 other location - About 55 mins to fix
        extensions/attachments.py on lines 144..147

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 37.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                if msg.getType() == "groupchat":
                    user = Chat.getUserObject(destination)
                else:
                    user = Users.get(destination)
        Severity: Minor
        Found in extensions/attachments.py and 1 other location - About 55 mins to fix
        extensions/sticker.py on lines 40..43

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 37.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def getPermissions(self):
                """
                Update the app permissions
                Returns:
                    The current permission mask
        Severity: Minor
        Found in gateway.py and 1 other location - About 55 mins to fix
        gateway.py on lines 570..578

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 37.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function add has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def add(cls, some_user):
                """
                Adds the User class object to poll
                """
                debug("longpoll: adding user to poll (jid: %s)", some_user.source)
        Severity: Minor
        Found in library/longpoll.py - About 55 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def getLists(self):
                """
                Receive the list of the user friends' groups
                Returns:
                    a list of user friends groups
        Severity: Minor
        Found in gateway.py and 1 other location - About 55 mins to fix
        gateway.py on lines 560..568

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 37.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function vcard_handler has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def vcard_handler(cl, iq):
            # Vcard feature makes transport hang (especially the photo part)
            # Many clients love to query vcards so much, so the solution was in adding a semaphore here and sleep() at the bottom
            # This is probably not a good idea, but for now this is the best one
            with VCARD_SEMAPHORE:
        Severity: Minor
        Found in modules/mod_iq_vcard.py - About 55 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 RegisterHandler has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def RegisterHandler(self, name, handler, typ="", ns="", xmlns=None, makefirst=0, system=0):
        Severity: Major
        Found in library/xmpp/dispatcher.py - About 50 mins to fix
          Severity
          Category
          Status
          Source
          Language