mrDoctorWho/vk4xmpp

View on GitHub
library/xmpp/simplexml.py

Summary

Maintainability
F
6 days
Test Coverage

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

    Function __init__ has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, tag=None, attrs={}, payload=[], parent=None, nsp=None, node_built=False, node=None):
            """
            Takes "tag" argument as the name of node (prepended by namespace, if needed and separated from it
            by a space), attrs dictionary as the set of arguments, payload list as the set of textual strings
            and child nodes that this node carries within itself and "parent" argument that is another node
    Severity: Minor
    Found in library/xmpp/simplexml.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

    Function __str__ has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def __str__(self, fancy=0):
            """
            Method used to dump node into textual representation.
            if "fancy" argument is set to True produces indented output for readability.
            """
    Severity: Minor
    Found in library/xmpp/simplexml.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

    Node has 36 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Node(object):
        """
        Node class describes syntax of separate XML Node. It have a constructor that permits node creation
        from set of "namespace name", attributes and payload of text strings and other nodes.
        It does not natively support building node from text string and uses NodeBuilder class for that purpose.
    Severity: Minor
    Found in library/xmpp/simplexml.py - About 4 hrs to fix

      Function getTags has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def getTags(self, name, attrs={}, namespace=None, one=0):
              """
              Filters all child nodes using specified arguments as filter.
              Returns the list of nodes found.
              """
      Severity: Minor
      Found in library/xmpp/simplexml.py - About 2 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 starttag has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def starttag(self, tag, attrs):
              """
              XML Parser callback. Used internally.
              """
              self.check_data_buffer()
      Severity: Minor
      Found in library/xmpp/simplexml.py - About 2 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 iterTags has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def iterTags(self, name, attrs={}, namespace=None):
              """
              Iterate over all children using specified arguments as filter.
              """
              for node in self.kids:
      Severity: Minor
      Found in library/xmpp/simplexml.py - About 2 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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, tag=None, attrs={}, payload=[], parent=None, nsp=None, node_built=False, node=None):
      Severity: Major
      Found in library/xmpp/simplexml.py - About 50 mins to fix

        Function addChild has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def addChild(self, name=None, attrs={}, payload=[], namespace=None, node=None):
        Severity: Minor
        Found in library/xmpp/simplexml.py - About 35 mins to fix

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

              def getCDATA(self):
                  """
                  Serialize node, dropping all tags and leaving CDATA intact.
                  That is effectively kills all formatting, leaving only text were contained in XML.
                  """
          Severity: Minor
          Found in library/xmpp/simplexml.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 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 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

          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

          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

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

                      if i < len(self.kids) and self.kids[i]:
                          pl.append(self.kids[i])
          Severity: Major
          Found in library/xmpp/simplexml.py and 1 other location - About 1 hr to fix
          library/xmpp/simplexml.py on lines 305..306

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

          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 i < len(self.data) and self.data[i]:
                          pl.append(self.data[i])
          Severity: Major
          Found in library/xmpp/simplexml.py and 1 other location - About 1 hr to fix
          library/xmpp/simplexml.py on lines 307..308

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

          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

                          for key in attrs.keys():
                              if key not in node.attrs or node.attrs[key] != attrs[key]:
          Severity: Major
          Found in library/xmpp/simplexml.py and 1 other location - About 1 hr to fix
          library/xmpp/simplexml.py on lines 370..371

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

          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

                          for key in attrs.keys():
                              if key not in node.attrs or node.attrs[key] != attrs[key]:
          Severity: Major
          Found in library/xmpp/simplexml.py and 1 other location - About 1 hr to fix
          library/xmpp/simplexml.py on lines 350..351

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

          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

          There are no issues that match your filters.

          Category
          Status