hackedteam/vector-edk

View on GitHub
AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py

Summary

Maintainability
F
2 mos
Test Coverage

File ElementTree.py has 837 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#
# ElementTree
# $Id: ElementTree.py 3440 2008-07-18 14:45:01Z fredrik $
#
# light-weight XML support for Python 2.3 and later.
Severity: Major
Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 2 days to fix

    Function _serialize_html has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
    Open

    def _serialize_html(write, elem, encoding, qnames, namespaces):
        tag = elem.tag
        text = elem.text
        if tag is Comment:
            write("<!--%s-->" % _escape_cdata(text, encoding))
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.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 _serialize_xml has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
    Open

    def _serialize_xml(write, elem, encoding, qnames, namespaces):
        tag = elem.tag
        text = elem.text
        if tag is Comment:
            write("<!--%s-->" % _encode(text, encoding))
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.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 _namespaces has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

    def _namespaces(elem, encoding, default_namespace=None):
        # identify namespaces used in this tree
    
        # maps qnames to *encoded* prefix:local names
        qnames = {None: None}
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 7 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 _default has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def _default(self, text):
            prefix = text[:1]
            if prefix == "&":
                # deal with undefined entities
                try:
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 3 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

    Element has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Element(object):
        # <tag attrib>text<child/>...</tag>tail
    
        ##
        # (Attribute) Element tag.
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 3 hrs to fix

      Function write has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def write(self, file_or_filename,
                    # keyword arguments
                    encoding=None,
                    xml_declaration=None,
                    default_namespace=None,
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.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 a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, source, events, parser):
              self._file = source
              self._events = []
              self._index = 0
              self.root = self._root = None
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.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 next has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def next(self):
              while 1:
                  try:
                      item = self._events[self._index]
                  except IndexError:

      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

      Avoid deeply nested control flow statements.
      Open

                          if isinstance(k, QName):
                              k = k.text
                          if isinstance(v, QName):
      Severity: Major
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if isinstance(k, QName):
                                k = k.text
                            if isinstance(v, QName):
        Severity: Major
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if isinstance(v, QName):
                                  v = qnames[v.text]
                              else:
                                  v = _escape_attrib_html(v, encoding)
                              # FIXME: handle boolean attributes
          Severity: Major
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 45 mins to fix

            Function write has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def write(self, file_or_filename,
            Severity: Minor
            Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  for v, k in sorted(namespaces.items(),
                                                     key=lambda x: x[1]):  # sort on prefix
                                      if k:
                                          k = ":" + k
                                      write(" xmlns%s=\"%s\"" % (
              Severity: Major
              Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 45 mins to fix

                Function itertext has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def itertext(self):
                        tag = self.tag
                        if not isinstance(tag, basestring) and tag is not None:
                            return
                        if self.text:
                Severity: Minor
                Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 45 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

                Avoid deeply nested control flow statements.
                Open

                                    for v, k in sorted(namespaces.items(),
                                                       key=lambda x: x[1]):  # sort on prefix
                                        if k:
                                            k = ":" + k
                                        write(" xmlns%s=\"%s\"" % (
                Severity: Major
                Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if isinstance(v, QName):
                                          v = qnames[v.text]
                                      else:
                                          v = _escape_attrib(v, encoding)
                                      write(" %s=\"%s\"" % (qnames[k], v))
                  Severity: Major
                  Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 45 mins to fix

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

                    def _serialize_html(write, elem, encoding, qnames, namespaces):
                    Severity: Minor
                    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 35 mins to fix

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

                      def _serialize_xml(write, elem, encoding, qnames, namespaces):
                      Severity: Minor
                      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.py - About 35 mins to fix

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

                            def __init__(self, html=0, target=None, encoding=None):
                                try:
                                    from xml.parsers import expat
                                except ImportError:
                                    try:
                        Severity: Minor
                        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.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 _flush has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _flush(self):
                                if self._data:
                                    if self._last is not None:
                                        text = "".join(self._data)
                                        if self._tail:
                        Severity: Minor
                        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.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 _escape_attrib has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def _escape_attrib(text, encoding):
                            # escape attribute value
                            try:
                                if "&" in text:
                                    text = text.replace("&", "&amp;")
                        Severity: Minor
                        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.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 iterfind has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def iterfind(self, element, tag, namespaces=None):
                                if tag[:3] == ".//":
                                    for elem in element.iter(tag[3:]):
                                        yield elem
                                for elem in element:
                        Severity: Minor
                        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/xml/etree/ElementTree.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

                        vector-uefi/fd/efi/StdLib/lib/python.27/xml/etree/ElementTree.py on lines 0..1648

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

                        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