mrDoctorWho/vk4xmpp

View on GitHub

Showing 283 of 283 total issues

Function is_active has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def is_active(self, flag):
        """
        If given flag(s) should generate output.
        """
        # try to abort early to quicken code
Severity: Minor
Found in library/xmpp/debug.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 Execute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def Execute(self, conn, request):
        """
        The method that handles all the commands, and routes them to the correct method for that stage.
        """
        # New request or old?
Severity: Minor
Found in library/xmpp/commands.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 13 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, name=None, to=None, typ=None, frm=None, attrs={}, payload=[], timestamp=None, xmlns=None, node=None):
        """
        Constructor, name is the name of the stanza i.e. "message" or "presence" or "iq".
        to is the value of "to" attribure, "typ" - "type" attribute
        frn - from attribure, attrs - other attributes mapping, payload - same meaning as for simplexml payload definition
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 receive has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def receive(self):
        """
        Reads all pending incoming data.
        In case of disconnection calls owner's disconnected() method and then raises IOError exception.
        """
Severity: Minor
Found in library/xmpp/transports.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 dictToDataForm has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def dictToDataForm(_dict, _fields=None):
    """
    Makes a buildForm()-compatible dict from a random key-value dict
    converts boolean types to a boolean field,
    converts multiline string to a text-multi field and so on.
Severity: Minor
Found in modules/mod_iq_disco.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 sendPhoto has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def sendPhoto(user, data, type, address, mType):
    mask = user.vk.permissions
    if mType == "chat_id":
        address = address.split("@")[0].split("#")[1]
        send = False
Severity: Minor
Found in modules/mod_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

    def setOptions(self, ls):
        """
        Set label-option pairs list associated with this field.
        """
        while self.getTag("option"):
Severity: Major
Found in library/xmpp/protocol.py and 1 other location - About 1 hr to fix
library/xmpp/protocol.py on lines 1064..1072

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

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 setValues(self, ls):
        """
        Set the values of this field as values-list.
        Replaces all previous filed values! If you need to just add a value - use addValue method.
        """
Severity: Major
Found in library/xmpp/protocol.py and 1 other location - About 1 hr to fix
library/xmpp/protocol.py on lines 1098..1105

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

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

    def makeHashes(self, user, uids=None):
        uids = uids or user.friends.keys()
        local = self.getLocalHashes(uids)
        if len(local) > 1:
            for uid in uids:
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 connect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def connect(self, server=None, proxy=None, secure=None, use_srv=True):
        """
        Connect to jabber server. If you want to specify different ip/port to connect to you can
        pass it as tuple as first parameter. If there is HTTP proxy between you and server
        specify it's address and credentials (if needed) in the second argument.
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 PresenceHandler has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def PresenceHandler(self, dis, pres):
        """
        Presence tracker. Used internally for setting items' resources state in
        internal roster representation.
        """
Severity: Minor
Found in library/xmpp/roster.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 confirm has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def confirm(self):
        """
        Confirms the application and receives the token
        """
        url = "https://oauth.vk.com/authorize/"
Severity: Minor
Found in library/vkapi.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 active_set has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def active_set(self, active_flags=None):
        """
        Returns 1 if any flags where actually set, otherwise 0.
        """
        r = 0
Severity: Minor
Found in library/xmpp/debug.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 SendHandler has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def SendHandler(self, conn):
        """
        Send next portion of data if it is time to do it. Used internally.
        """
        self.DEBUG("SendHandler called", "info")
Severity: Minor
Found in library/xmpp/filetransfer.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 11 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

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

    def _(what):
        if what:
            name = "%s/locales/locale.%s" % (path, locale)
            what = what.replace("\n", "\\n")
            if locale != "en" and os.path.exists(name):
    Severity: Minor
    Found in library/stext.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 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

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

          def update(self, userObject):
              """
              Updates chat users and sends messages
              Uses two user lists to prevent losing of any of them
              """
      Severity: Minor
      Found in extensions/groupchats.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 user_activity_remove has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def user_activity_remove():
          users = runDatabaseQuery("select * from last_activity", many=True)
          LA = utils.TimeMachine(USER_LIFETIME_LIMIT)
          for (jid, date) in users:
              if (time.time() - date) >= LA:
      Severity: Minor
      Found in extensions/user_activity.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 Process has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def Process(self, timeout=8):
              """
              Check incoming stream for data waiting. If "timeout" is positive - block for as max. this time.
              Returns:
              1) length of processed data if some data were processed;
      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

      Severity
      Category
      Status
      Source
      Language