mrDoctorWho/vk4xmpp

View on GitHub

Showing 283 of 283 total issues

Function commands_handler has a Cognitive Complexity of 210 (exceeds 5 allowed). Consider refactoring.
Open

def commands_handler(cl, iq):
    source = iq.getFrom().getStripped()
    cmd = iq.getTag("command", namespace=xmpp.NS_COMMANDS)
    if cmd:
        result = iq.buildReply("result")
Severity: Minor
Found in modules/mod_iq_disco.py - About 4 days 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

File protocol.py has 1259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

##   protocol.py
##
##   Copyright (C) 2003-2005 Alexey "Snake" Nezhdanov
##
##   This program is free software; you can redistribute it and/or modify
Severity: Major
Found in library/xmpp/protocol.py - About 3 days to fix

    File gateway.py has 1112 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python2
    # coding: utf-8
    
    # vk4xmpp gateway, v3.6
    # © simpleApps, 2013 — 2018.
    Severity: Major
    Found in gateway.py - About 2 days to fix

      Function parseAttachments has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
      Open

      def parseAttachments(self, msg, spacer=""):
          """
          “parses” attachments from the json to a string
          """
          result = (MSG_APPEND, "")
      Severity: Minor
      Found in extensions/attachments.py - About 1 day 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

      File simplexml.py has 620 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      ##   simplexml.py based on Mattew Allum's xmlstream.py
      ##
      ##   Copyright (C) 2003-2005 Alexey "Snake" Nezhdanov
      ##
      ##   This program is free software; you can redistribute it and/or modify
      Severity: Major
      Found in library/xmpp/simplexml.py - About 1 day to fix

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

            def asDict(self):
                """
                Represent dataform as simple dictionary mapping of datafield names to their values.
                """
                ret = {}
        Severity: Major
        Found in library/xmpp/protocol.py and 2 other locations - About 1 day to fix
        library/xmpp/protocol.py on lines 1182..1199
        library/xmpp/protocol.py on lines 1253..1270

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

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

            def asDict(self):
                """
                Represent dataitem as simple dictionary mapping of datafield names to their values.
                """
                ret = {}
        Severity: Major
        Found in library/xmpp/protocol.py and 2 other locations - About 1 day to fix
        library/xmpp/protocol.py on lines 1253..1270
        library/xmpp/protocol.py on lines 1400..1417

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

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

            def asDict(self):
                """
                Represent dataitem as simple dictionary mapping of datafield names to their values.
                """
                ret = {}
        Severity: Major
        Found in library/xmpp/protocol.py and 2 other locations - About 1 day to fix
        library/xmpp/protocol.py on lines 1182..1199
        library/xmpp/protocol.py on lines 1400..1417

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

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

        def presence_handler(cl, prs):
            pType = prs.getType()
            jidFrom = prs.getFrom()
            source = jidFrom.getStripped()
            resource = jidFrom.getResource()
        Severity: Minor
        Found in modules/mod_prs_main.py - About 1 day 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 dispatch has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
        Open

            def dispatch(self, stanza, session=None, direct=0):
                """
                Main procedure that performs XMPP stanza recognition and calling apppropriate handlers for it.
                Called internally.
                """
        Severity: Minor
        Found in library/xmpp/dispatcher.py - About 1 day 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 register_handler has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
        Open

        def register_handler(cl, iq):
            source = iq.getFrom().getStripped()
            destination = iq.getTo().getStripped()
            result = iq.buildReply("result")
            if USER_LIMIT:
        Severity: Minor
        Found in modules/mod_iq_register.py - About 1 day 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

        File groupchats.py has 493 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # coding: utf-8
        # This file is a part of VK4XMPP transport
        # © simpleApps, 2013 — 2018.
        
        # Installation:
        Severity: Minor
        Found in extensions/groupchats.py - About 7 hrs to fix

          Function method has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
          Open

              def method(self, method, values=None, notoken=False):
                  """
                  Executes a VK method
                  Args:
                      method: vk method
          Severity: Minor
          Found in library/vkapi.py - About 6 hrs 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

          File dispatcher.py has 433 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          ##   transports.py
          ##
          ##   Copyright (C) 2003-2005 Alexey "Snake" Nezhdanov
          ##
          ##   This program is free software; you can redistribute it and/or modify
          Severity: Minor
          Found in library/xmpp/dispatcher.py - About 6 hrs to fix

            File vkapi.py has 427 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # coding: utf-8
            # © simpleApps, 2013 — 2016.
            
            """
            Manages VK API requests
            Severity: Minor
            Found in library/vkapi.py - About 6 hrs to fix

              Function incoming_message_handler has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
              Open

              def incoming_message_handler(cl, msg):
                  """
                  Handles incoming (xmpp) messages and sends them to VK
                  """
                  if msg.getType() == "groupchat":
              Severity: Minor
              Found in modules/mod_groupchat_msg.py - About 6 hrs 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 handleChatPresences has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
              Open

              def handleChatPresences(source, prs):
                  """
                  Makes the old users leave
                  Args:
                      source: stanza source
              Severity: Minor
              Found in modules/mod_groupchat_prs.py - About 5 hrs 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 2 locations. Consider refactoring.
              Open

                      if not fancy and (len(self.data) - 1) >= cnt:
                          s += XMLescape(self.data[cnt])
                      elif (len(self.data) - 1) >= cnt:
                          s += XMLescape(self.data[cnt].strip())
              Severity: Major
              Found in library/xmpp/simplexml.py and 1 other location - About 5 hrs to fix
              library/xmpp/simplexml.py on lines 162..165

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

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

                              if not fancy and (len(self.data) - 1) >= cnt:
                                  s += XMLescape(self.data[cnt])
                              elif (len(self.data) - 1) >= cnt:
                                  s += XMLescape(self.data[cnt].strip())
              Severity: Major
              Found in library/xmpp/simplexml.py and 1 other location - About 5 hrs to fix
              library/xmpp/simplexml.py on lines 171..174

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

              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

              File transports.py has 409 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              ##   transports.py
              ##
              ##   Copyright (C) 2003-2004 Alexey "Snake" Nezhdanov
              ##
              ##   This program is free software; you can redistribute it and/or modify
              Severity: Minor
              Found in library/xmpp/transports.py - About 5 hrs to fix
                Severity
                Category
                Status
                Source
                Language