mrDoctorWho/vk4xmpp

View on GitHub

Showing 283 of 283 total issues

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

    Avoid deeply nested control flow statements.
    Open

                        if tid > 0:
                            name = "%s's" % name_
                        else:
                            name = "“%s”" % name_
    
    
    Severity: Major
    Found in extensions/attachments.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if x == "'":
                              text += Nocolor
                              break
                  elif c.isdigit():
      Severity: Major
      Found in library/printer.py - About 45 mins to fix

        Function ReceiveHandler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def ReceiveHandler(self, conn, stanza):
                """
                Receive next portion of incoming datastream and store it write
                it to temporary file. Used internally.
                """
        Severity: Minor
        Found in library/xmpp/filetransfer.py - About 45 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 asDict has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

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

            def RegisterHandler(self, name, handler, typ="", ns="", xmlns=None, makefirst=0, system=0):
                """Register user callback as stanzas handler of declared type. Callback must take
                (if chained, see later) arguments: dispatcher instance (for replying), incomed
                return of previous handlers.
                The callback must raise xmpp.NodeProcessed just before return if it want preven
        Severity: Minor
        Found in library/xmpp/dispatcher.py - About 45 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 UnregisterHandler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def UnregisterHandler(self, name, handler, typ="", ns="", xmlns=None):
                """
                Unregister handler. "typ" and "ns" must be specified exactly the same as with registering.
                """
                if not xmlns:
        Severity: Minor
        Found in library/xmpp/dispatcher.py - About 45 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 deeply nested control flow statements.
        Open

                            if found:
                                break
        
        
        Severity: Major
        Found in extensions/attachments.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for key in dictForm.keys():
                                  if key in config:
                                      config[key] = utils.normalizeValue(dictForm[key])
                              note = "The settings were changed."
          Severity: Major
          Found in modules/mod_iq_disco.py - About 45 mins to fix

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

                    Protocol.__init__(self, "presence", to=to, typ=typ, attrs=attrs, frm=frm, payload=payload, timestamp=timestamp, xmlns=xmlns, node=node)
            Severity: Minor
            Found in library/xmpp/protocol.py and 1 other location - About 45 mins to fix
            library/xmpp/protocol.py on lines 669..669

            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 35.

            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

            Avoid deeply nested control flow statements.
            Open

                                if name in STAT_FIELDS:
                                    attr = STAT_FIELDS[name]
                                    value = stats[attr].pop(0)
                                    node = xmpp.Node("stat", {"units": attr})
                                    node.setAttr("name", name)
            Severity: Major
            Found in modules/mod_iq_stats.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if chats:
                                      _fields = dictToDataForm(dict([(chat[0], False) for chat in chats]))
                                      simpleForm = buildForm(simpleForm, fields=_fields, title="Delete chats")
                                  else:
                                      note = "Nothing to delete"
              Severity: Major
              Found in modules/mod_iq_disco.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    with user.sync:
                                        user.vk.sendMessage(body, chatId, "chat_id")
                                    if chat.isUpdateRequired():
                Severity: Major
                Found in modules/mod_groupchat_msg.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if "&" in token or "=" in token:
                                          match = api.token_exp.search(token)
                                          if match:
                                              token = match.group(1)
                                              # get rid of unnecessary data (if present)
                  Severity: Major
                  Found in modules/mod_iq_register.py - About 45 mins to fix

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

                            hash = hashlib.sha1(owner.Dispatcher.Stream._document_attrs["id"] + self.password).hexdigest()
                    Severity: Minor
                    Found in library/xmpp/auth.py and 1 other location - About 45 mins to fix
                    library/xmpp/auth.py on lines 72..72

                    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 35.

                    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

                    Avoid deeply nested control flow statements.
                    Open

                                        if not form:
                                            simpleForm = buildForm(simpleForm,
                                                fields=[{"var": "token", "type": "text-single", "label": "API Token"}],
                                                title=_("Enter the API token"))
                                        else:
                    Severity: Major
                    Found in modules/mod_iq_disco.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if not form:
                                              _fields = dictToDataForm(dict([(mod, mod in Manager.loaded) for mod in modules]))
                                              simpleForm = buildForm(simpleForm, fields=_fields, title="(Re)load modules",
                                                  data=[_("Modules can be loaded or reloaded if they already loaded")])
                      
                      
                      Severity: Major
                      Found in modules/mod_iq_disco.py - About 45 mins to fix

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

                            def getTo(self):
                                """
                                Return value of the "to" attribute.
                                """
                                try:
                        Severity: Minor
                        Found in library/xmpp/protocol.py and 1 other location - About 45 mins to fix
                        library/xmpp/protocol.py on lines 548..556

                        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 35.

                        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 getFrom(self):
                                """
                                Return value of the "from" attribute.
                                """
                                try:
                        Severity: Minor
                        Found in library/xmpp/protocol.py and 1 other location - About 45 mins to fix
                        library/xmpp/protocol.py on lines 538..546

                        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 35.

                        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 handleUser has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def handleUser(cls, user):
                                """
                                Tries to reinitialize poll for LONGPOLL_RETRY_COUNT every LONGPOLL_RETRY_TIMEOUT seconds
                                As soon as poll is initialized the user will be removed from buffer
                                Args:
                        Severity: Minor
                        Found in library/longpoll.py - About 45 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