mrDoctorWho/vk4xmpp

View on GitHub

Showing 283 of 283 total issues

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

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

                        Protocol.__init__(self, "message", 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 732..732

                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 item:
                                            continue
                                        messages.extend(item)
                Severity: Major
                Found in gateway.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if not form:
                                          _fields = dictToDataForm(dict([(mod, False) for mod in modules]))
                                          if _fields:
                                              simpleForm = buildForm(simpleForm, fields=_fields, title="Unload modules")
                                          else:
                  Severity: Major
                  Found in modules/mod_iq_disco.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if chat.isUpdateRequired():
                                            updateLastUsed(chat)
                                        raise xmpp.NodeProcessed()
                    Severity: Major
                    Found in modules/mod_groupchat_msg.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if user.sendMessage(body, uID, mid=mid):
                                              # check if the client requested the message to be marked as received
                                              if msg.getTag("request", namespace=xmpp.NS_RECEIPTS):
                                                  answer = reportReceived(msg, jidFrom, jidTo)
                                  if answer:
                      Severity: Major
                      Found in modules/mod_msg_main.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 104..104

                        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": "filename", "type": "list-single", "label": "Filename",
                                                        "options": os.listdir("crash") if os.path.exists("crash") else []}],
                                                    title="Choose wisely")
                        Severity: Major
                        Found in modules/mod_iq_disco.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if not form:
                                                  simpleForm = buildForm(simpleForm, fields=getConfigFields(config), title="Choose wisely")
                          
                                              elif form:
                                                  for key in dictForm.keys():
                          Severity: Major
                          Found in modules/mod_iq_disco.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if (time.gmtime().tm_mon, time.gmtime().tm_mday) == (4, 1):
                                                    setAffiliation(source, "outcast", jid, reason=_("Get the hell outta here!"))
                                                else:
                                                    leaveChat(source, jid)
                            
                            
                            Severity: Major
                            Found in modules/mod_groupchat_prs.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if text == "!captcha" and args:
                                                      acceptCaptcha(args, source, jidTo)
                                                      answer = reportReceived(msg, jidFrom, jidTo)
                              
                              
                              Severity: Major
                              Found in modules/mod_msg_main.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

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

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if self.settings.force_vk_date or init:
                                                              date = message["date"]
                                                          self.lastMsgByUser[frm] = mid
                                  Severity: Major
                                  Found in gateway.py - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language