mrDoctorWho/vk4xmpp

View on GitHub

Showing 227 of 283 total issues

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

      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

              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

                  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

                  Avoid deeply nested control flow statements.
                  Open

                                      if not form:
                                          simpleForm = buildForm(simpleForm,
                                              fields=[
                                                  {"var": "subject", "type": "text-single", "label": _("Subject"), "value": "Announcement"},
                                                  {"var": "body", "type": "text-multi", "label": _("Message"), "required": True},
                  Severity: Major
                  Found in modules/mod_iq_disco.py - About 45 mins to fix

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

                        def sendInitPresence(self):
                            """
                            Sends available presence to the user from all online friends
                            """
                            if not self.vk.engine.captcha:
                    Severity: Minor
                    Found in gateway.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 not attachments and not chat:
                                            message = [{"out": 0, "from_id": uid, "id": mid, "date": date, "text": body}]
                                        # we substract 1 from msg id b/c VK now has reverse history so we need to ask what happened before this exact message
                                        utils.runThread(user.sendMessages, (False, message, mid - 1, uid), "sendMessages-%s" % user.source)
                    Severity: Major
                    Found in library/longpoll.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if not form:
                                              simpleForm = buildForm(simpleForm,
                                                  fields=[{"var": "jids", "type": "jid-multi", "label": _("Jabber ID's"), "required": True}])
                                          else:
                                              if dictForm.get("jids"):
                      Severity: Major
                      Found in modules/mod_iq_disco.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if user.friends[id]["online"]:
                                                sendPresence(source, destination, hash=USER_CAPS_HASH)
                                    if destination == TransportID:
                        Severity: Major
                        Found in modules/mod_prs_main.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if jid != TransportID:
                                                  runDatabaseQuery("update groupchats set owner=? where jid=?", (source, jid), set=True)
                          
                          
                          Severity: Major
                          Found in modules/mod_groupchat_prs.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if not phone or phone == "+":
                                                    result = utils.buildIQError(iq, xmpp.ERR_BAD_REQUEST, _("Phone is incorrect."))
                                            else:
                            Severity: Major
                            Found in modules/mod_iq_register.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if status == MSG_SKIP:
                                                          for func in iter_:
                                                              utils.execute(func, (self, message))
                                                          break
                                                      elif status == MSG_APPEND:
                              Severity: Major
                              Found in gateway.py - About 45 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language