hackedteam/vector-edk

View on GitHub
vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.py

Summary

Maintainability
F
2 mos
Test Coverage

File expatbuilder.py has 785 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Facility to use the Expat parser to load a minidom instance
from a string or file.

This avoids all the overhead of SAX and pulldom to gain performance.
"""
Severity: Major
Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.py - About 1 day to fix

    ExpatBuilder has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ExpatBuilder:
        """Document builder that uses Expat to build a ParsedXML.DOM document
        instance."""
    
        def __init__(self, options=None):
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.py - About 3 hrs to fix

      Function _getDeclarations has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def _getDeclarations(self):
              """Re-create the internal subset from the DocumentType node.
      
              This is only needed if we don't already have the
              internalSubset as a string.
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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

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

          def _getNSattrs(self):
              """Return string of namespace attributes from this element and
              ancestors."""
              # XXX This needs to be re-written to walk the ancestors of the
              # context to build up the namespace information from
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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 start_element_handler has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def start_element_handler(self, name, attributes):
              if ' ' in name:
                  uri, localname, prefix, qname = _parse_ns_name(self, name)
              else:
                  uri = EMPTY_NAMESPACE
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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 acceptNode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def acceptNode(self, node):
              mask = self._nodetype_mask[node.nodeType]
              if self.filter.whatToShow & mask:
                  val = self.filter.acceptNode(node)
                  if val == FILTER_INTERRUPT:
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.py - About 1 hr 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 entity_decl_handler has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def entity_decl_handler(self, entityName, is_parameter_entity, value,
      Severity: Major
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.py - About 50 mins to fix

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

            def attlist_decl_handler(self, elem, name, type, default, required):
        Severity: Minor
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.py - About 35 mins to fix

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

              def _finish_start_element(self, node):
                  if self._filter:
                      # To be general, we'd have to call isSameNode(), but this
                      # is sufficient for minidom:
                      if node is self.document.documentElement:
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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 _handle_white_text_nodes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def _handle_white_text_nodes(self, node, info):
                  if (self._options.whitespace_in_element_content
                      or not info.isElementContent()):
                      return
          
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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 getAttributeType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def getAttributeType(self, aname):
                  for info in self._attr_info:
                      if info[1] == aname:
                          t = info[-2]
                          if t[0] == "(":
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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 parseString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def parseString(self, string):
                  """Parse a document fragment from a string, returning the
                  fragment node."""
                  self._source = string
                  parser = self.getParser()
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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 parseFile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def parseFile(self, file):
                  """Parse a document from a file object, returning the document
                  node."""
                  parser = self.getParser()
                  first_buffer = True
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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 _finish_end_element has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _finish_end_element(self, curNode):
                  info = self._elem_info.get(curNode.tagName)
                  if info:
                      self._handle_white_text_nodes(curNode, info)
                  if self._filter:
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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 character_data_handler_cdata has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def character_data_handler_cdata(self, data):
                  childNodes = self.curNode.childNodes
                  if self._cdata:
                      if (  self._cdata_continue
                            and childNodes[-1].nodeType == CDATA_SECTION_NODE):
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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 startContainer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def startContainer(self, node):
                  mask = self._nodetype_mask[node.nodeType]
                  if self.filter.whatToShow & mask:
                      val = self.filter.startContainer(node)
                      if val == FILTER_INTERRUPT:
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/xml/dom/expatbuilder.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

          AppPkg/Applications/Python/Python-2.7.2/Lib/xml/dom/expatbuilder.py on lines 0..983

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

          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