mrDoctorWho/vk4xmpp

View on GitHub

Showing 283 of 283 total issues

Function parseForwardedMessages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def parseForwardedMessages(self, msg, depth=0):
    body = ""
    result = (MSG_APPEND, "")
    if msg.get("fwd_messages"):
        spacer = BASE_SPACER * depth
Severity: Minor
Found in extensions/forwarded_messages.py - About 35 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 parseReplyMessages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def parseReplyMessages(self, msg):
    body = ""
    result = (MSG_APPEND, "")
    if msg.get("reply_message"):
        # todo: add date if the message wasn't sent today
Severity: Minor
Found in extensions/reply.py - About 35 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 login has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def login(self):
        """
        Logging in using password
        """
        url = "https://login.vk.com/"
Severity: Minor
Found in library/vkapi.py - About 35 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 StreamBrokenHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def StreamBrokenHandler(self, conn, stanza):
        """
        Handle stream closure due to all some error while receiving data.
        Raise xmpppy event specifying unsuccessfull data receive.
        """
Severity: Minor
Found in library/xmpp/filetransfer.py - About 35 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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, node=None):
        """
        Create new empty "reported data" field. However, note that, according XEP-0004:
        * It MUST contain one or more DataFields.
        * Contained DataFields SHOULD possess a "type" and "label" attribute in addition to "var" attribute
Severity: Minor
Found in library/xmpp/protocol.py - About 35 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 _CommandHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _CommandHandler(self, conn, request):
        """
        The internal method to process the routing of command execution requests.
        """
        # This is the command handler itself.
Severity: Minor
Found in library/xmpp/commands.py - About 35 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 getUserObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def getUserObject(source):
        """
        Gets user object by chat jid
        """
        user = None
Severity: Minor
Found in extensions/groupchats.py - About 35 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 FeaturesHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def FeaturesHandler(self, conn, feats):
        """
        Used to determine if server supports SASL auth. Used internally.
        """
        if not feats.getTag("mechanisms", namespace=NS_SASL):
Severity: Minor
Found in library/xmpp/auth.py - About 35 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 main_iq_handler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def main_iq_handler(cl, iq):
    source = iq.getFrom()
    if WhiteList:
        if source and source.getDomain() not in WhiteList:
            sender(cl, utils.buildIQError(iq, xmpp.ERR_BAD_REQUEST, "You're not in the white-list"))
Severity: Minor
Found in modules/mod_iq_main.py - About 35 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 getPeerIds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def getPeerIds(conversations, source=None):
        """
        Returns a list of peer ids that exist in the given conversations
        Args:
            conversations: list of Conversations objects
Severity: Minor
Found in gateway.py - About 35 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

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

        if typ in self.handlers[xmlns][name]:
            ls.append(typ) # from very common...
Severity: Minor
Found in library/xmpp/dispatcher.py and 1 other location - About 35 mins to fix
library/xmpp/dispatcher.py on lines 376..377

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

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

def getFeatures(destination, source, ns, disco=False):
    if destination == TransportID:
        features = TransportFeatures
    else:
        features = UserFeatures
Severity: Minor
Found in modules/mod_iq_disco.py - About 35 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

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

        elif key == KEY_PHONE_HOME and value:
            tel = vcard.getTag(KEY_TEL) or vcard.setTag(KEY_TEL)
            tel.setTagData(KEY_PHONE_HOME, value)
Severity: Minor
Found in modules/mod_iq_vcard.py and 1 other location - About 35 mins to fix
modules/mod_iq_vcard.py on lines 85..87

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

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

        elif key == KEY_PHONE_MOBILE and value:
            tel = vcard.getTag(KEY_TEL) or vcard.setTag(KEY_TEL)
            tel.setTagData(KEY_NUMBER, value)
Severity: Minor
Found in modules/mod_iq_vcard.py and 1 other location - About 35 mins to fix
modules/mod_iq_vcard.py on lines 89..91

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

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

    def __init__(self, source, user=True):
        """
        Uses GLOBAL_USER_SETTINGS variable as default user's settings
        and updates it using settings read from the file
        """
Severity: Minor
Found in library/settings.py - About 35 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 getUserData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def getUserData(self, uid, fields=None):
        """
        Gets user data. Such as name, photo, etc
        Args:
            uid: the user id (list or str)
Severity: Minor
Found in gateway.py - About 35 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

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

            if prop in self.handlers[xmlns][name]:
                ls.append(prop)
Severity: Minor
Found in library/xmpp/dispatcher.py and 1 other location - About 35 mins to fix
library/xmpp/dispatcher.py on lines 373..374

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

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 too many return statements within this function.
Open

            return self.connected
Severity: Major
Found in library/xmpp/client.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return self.connected
    Severity: Major
    Found in library/xmpp/client.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return "ok"
      Severity: Major
      Found in library/xmpp/transports.py - About 30 mins to fix
        Severity
        Category
        Status
        Source
        Language