mrDoctorWho/vk4xmpp

View on GitHub

Showing 283 of 283 total issues

Function manageRoster has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def manageRoster(cls, user, jid, dist={}, action="add"):
        def answer(cl, stanza):
            if xmpp.isResultNode(stanza):
                logger.debug("Roster has been successfully set (jid: %s)", jid)
                user.markRosterSet()
Severity: Minor
Found in library/rostermanager.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 reconnectAndReauth has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def reconnectAndReauth(self, handlerssave=None):
        """
        Example of reconnection method. In fact, it can be used to batch connection and auth as well.
        """
        Dispatcher_ = False
Severity: Minor
Found in library/xmpp/client.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 captcha_handler has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def captcha_handler(cl, iq):
    if iq.getTagAttr("captcha", "xmlns") == xmpp.NS_CAPTCHA:
        source = iq.getFrom().getStripped()
        result = iq.buildReply("result")
        if source in Users:
Severity: Minor
Found in modules/mod_iq_captcha.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 xhtml_handler has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def xhtml_handler(cl, msg):
    destination = msg.getTo().getStripped()
    source = msg.getFrom()
    if isinstance(source, (str, unicode)):
        logger.warning("Received message did not contain a valid jid: %s", msg)
Severity: Minor
Found in modules/mod_msg_xhtml.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

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

    if fb2b and not isResultNode(rep):
        rep = disp.SendAndWaitForResponse(Iq(to=jid, typ="get", queryNS=NS_BROWSE)) # Fallback to browse
Severity: Major
Found in library/xmpp/features.py and 1 other location - About 1 hr to fix
library/xmpp/features.py on lines 44..45

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

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

    if fb2a and not isResultNode(rep):
        rep = disp.SendAndWaitForResponse(Iq(to=jid, typ="get", queryNS=NS_AGENTS)) # Fallback to agents
Severity: Major
Found in library/xmpp/features.py and 1 other location - About 1 hr to fix
library/xmpp/features.py on lines 42..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 40.

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 __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

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

        def __init__(self, transport, port=5347, typ=None, debug=["always", "nodebuilder"], domains=None, sasl=0, bind=0, route=0, xcp=0):
    Severity: Major
    Found in library/xmpp/client.py - About 1 hr to fix

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

      def attachments_msg03(msg, destination, source):
          body = msg.getBody()
          if body:
              if msg.getType() == "groupchat":
                  user = Chat.getUserObject(destination)
      Severity: Minor
      Found in extensions/attachments.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, jid=None, node="", domain="", resource=""):
              """
              Constructor. JID can be specified as string (jid argument) or as separate parts.
              Examples:
              JID("node@domain/resource")
      Severity: Minor
      Found in library/xmpp/protocol.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 plugin has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def plugin(self, owner):
              """
              Determine the best auth method (digest/0k/plain) and use it for auth.
              Returns used method name on success. Used internally.
              """
      Severity: Minor
      Found in library/xmpp/auth.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 addPresenceHash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def addPresenceHash(prs, destination, source):
          if destination in Users and not prs.getType():
              user = Users[destination]
              if user.settings.avatar_hash:
                  x = prs.setTag("x", namespace=xmpp.NS_VCARD_UPDATE)
      Severity: Minor
      Found in extensions/avatar_hash.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 auth has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def auth(self, name, password, dup=None):
              """
              Authenticate component "name" with password "password".
              """
              self._User, self._Password, self._Resource = name, password, ""
      Severity: Minor
      Found in library/xmpp/client.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 Bind has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def Bind(self, resource=None):
              """
              Perform binding. Use provided resource name or random (if not provided).
              """
              while self.bound is None and self._owner.Process(1):
      Severity: Minor
      Found in library/xmpp/auth.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 send has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def send(self, stanza):
              """
              Serialize stanza and put it on the wire. Assign an unique ID to it before send.
              Returns assigned ID.
              """
      Severity: Minor
      Found in library/xmpp/dispatcher.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

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

          def __getitem__(self, name):
              """
              Simple dictionary interface for getting datafields values by their names.
              """
              item = self.getField(name)
      Severity: Major
      Found in library/xmpp/protocol.py and 2 other locations - About 1 hr to fix
      library/xmpp/protocol.py on lines 1272..1279
      library/xmpp/protocol.py on lines 1419..1426

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

      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 3 locations. Consider refactoring.
      Open

          def __getitem__(self, name):
              """
              Simple dictionary interface for getting datafields values by their names.
              """
              item = self.getField(name)
      Severity: Major
      Found in library/xmpp/protocol.py and 2 other locations - About 1 hr to fix
      library/xmpp/protocol.py on lines 1201..1208
      library/xmpp/protocol.py on lines 1272..1279

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

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

          def watchdog(cls):
              while cls.watchdog:
                  for sock, (user, opener) in cls.__list.items():
                      if (time.time() - opener.created) > OPENER_LIFETIME:
                          with cls.__lock:
      Severity: Minor
      Found in library/longpoll.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

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

          def __getitem__(self, name):
              """
              Simple dictionary interface for getting datafields values by their names.
              """
              item = self.getField(name)
      Severity: Major
      Found in library/xmpp/protocol.py and 2 other locations - About 1 hr to fix
      library/xmpp/protocol.py on lines 1201..1208
      library/xmpp/protocol.py on lines 1419..1426

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

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

      def buildDataForm(form=None, type="form", fields=[], title=None, data=[]):
          """
          Provides easier method to build data forms using dict for each form object
          Parameters:
              form: xmpp.DataForm object
      Severity: Minor
      Found in library/utils.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

      Severity
      Category
      Status
      Source
      Language