mrDoctorWho/vk4xmpp

View on GitHub

Showing 283 of 283 total issues

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

            if isinstance(handler, dict):
                lst = handler["items"]
            else:
                lst = handler(conn, request, "items")
Severity: Minor
Found in library/xmpp/browser.py and 1 other location - About 30 mins to fix
library/xmpp/browser.py on lines 245..248

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

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 isinstance(handler, dict):
                dt = handler["info"]
            else:
                dt = handler(conn, request, "info")
Severity: Minor
Found in library/xmpp/browser.py and 1 other location - About 30 mins to fix
library/xmpp/browser.py on lines 235..238

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

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

    def WaitForResponse(self, ID, timeout=DefaultTimeout):
        """
        Block and wait until stanza with specific "id" attribute will come.
        If no such stanza is arrived within timeout, return None.
        If operation failed for some reason then owner's attributes
Severity: Minor
Found in library/xmpp/dispatcher.py - About 25 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 StreamOpenHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def StreamOpenHandler(self, conn, stanza):
        """
        Handles opening of new incoming stream. Used internally.
        """
        err = None
Severity: Minor
Found in library/xmpp/filetransfer.py - About 25 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 statusfromvk_prs02 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def statusfromvk_prs02(prs, destination, source):
    if source != TransportID and destination in Users:
        user = Users[destination]
        if user.settings.status_from_vk and not prs.getType():
            id = vk2xmpp(source)
Severity: Minor
Found in extensions/status.py - About 25 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 alive_keeper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def alive_keeper():
    logger.debug("alive_keeper has started!")

    def alive_keeper_answer(cl, stanza):
        logger.debug("alive_keeper: answer received, continuing iteration")
Severity: Minor
Found in extensions/alive_keeper.py - About 25 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 endtag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def endtag(self, tag):
        """
        XML Parser callback. Used internally.
        """
        self.DEBUG(DBG_NODEBUILDER, "DEPTH -> %i , tag -> %s" % (self.__depth, tag), "up")
Severity: Minor
Found in library/xmpp/simplexml.py - About 25 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 _validate_flag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _validate_flag(self, flags):
        """
        Verify that flag is defined.
        """
        if flags:
Severity: Minor
Found in library/xmpp/debug.py - About 25 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 getError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def getError(self):
        """
        Return the error-condition (if present) or the textual description of the error (otherwise).
        """
        errtag = self.getTag("error")
Severity: Minor
Found in library/xmpp/protocol.py - About 25 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 handleQueue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def handleQueue():
    while ALIVE:
        if Queue:
            user = Queue.pop()
            user.hashes = Avatars.makeHashes(user)
Severity: Minor
Found in extensions/avatar_hash.py - About 25 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 _muc_getSubTagDataAttr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _muc_getSubTagDataAttr(self, tag, attr):
        for xtag in self.getTags("x", namespace=NS_MUC_USER):
            for child in xtag.getTags("item"):
                for cchild in child.getTags(tag):
                    return cchild.getData(), cchild.getAttr(attr)
Severity: Minor
Found in library/xmpp/protocol.py - About 25 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 PlugIn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def PlugIn(self, owner):
        """
        Attach to main instance and register ourself and all our staff in it.
        """
        self._owner = owner
Severity: Minor
Found in library/xmpp/plugin.py - About 25 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 PlugIn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def PlugIn(self, owner, now=0):
        """
        If the 'now' argument is true then starts using encryption immidiatedly.
        If 'now' in false then starts encryption as soon as TLS feature is
        declared by the server (if it were already declared - it is ok).
Severity: Minor
Found in library/xmpp/transports.py - About 25 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 is_active has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def is_active(self, flag):
        if not self.active:
            return 0
        if not flag or flag in self.active and DBG_ALWAYS not in self.active or flag not in self.active and DBG_ALWAYS in self.active:
            return 1
Severity: Minor
Found in library/xmpp/debug.py - About 25 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 getUserByID has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def getUserByID(id):
        for user in Users.values():
            if hasattr(user, "vk"):
                if user.vk.getUserPreferences()[0] == id:
                    return user
Severity: Minor
Found in extensions/groupchats.py - About 25 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 checkRosterx has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def checkRosterx(cls, user, resource):
        """
        Checks if the client supports XEP-0144: Roster Item Exchange
        If it doesn't, or it didn't answer us, then transport will use the old method
        """
Severity: Minor
Found in library/rostermanager.py - About 25 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 getPayload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def getPayload(self):
        """
        Return the payload of node i.e. list of child nodes and CDATA entries.
        F.e. for "<node>text1<nodea/><nodeb/> text2</node>" will be returned list:
        ["text1", <nodea instance>, <nodeb instance>, " text2"].
Severity: Minor
Found in library/xmpp/simplexml.py - About 25 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 send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def send(self, data):
        """
        Writes raw outgoing data. Blocks until done.
        If supplied data is unicode string, encodes it to utf-8 before send.
        """
Severity: Minor
Found in library/xmpp/transports.py - About 25 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 IqHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def IqHandler(self, conn, stanza):
        """
        Handles streams state change. Used internally.
        """
        typ = stanza.getType()
Severity: Minor
Found in library/xmpp/filetransfer.py - About 25 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(self, force=False, send=True, resource=None, first=False):
        """
        Initializes user after the connection has been completed
        Args:
            force: force sending subscription presence
Severity: Minor
Found in gateway.py - About 25 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