hackedteam/vector-edk

View on GitHub
vector-uefi/fd/tool/chipsec/xmlout.py

Summary

Maintainability
F
4 days
Test Coverage

Function build_xml has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    def build_xml(self):
        """Builds the XML elements."""
        ts_attributes                  = dict()
        if self.name:
            ts_attributes["name"]      = str( self.name )
Severity: Minor
Found in vector-uefi/fd/tool/chipsec/xmlout.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 xmlout.py has 346 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/local/bin/python
#CHIPSEC: Platform Security Assessment Framework
#Copyright (c) 2010-2014, Intel Corporation
# 
#This program is free software; you can redistribute it and/or
Severity: Minor
Found in vector-uefi/fd/tool/chipsec/xmlout.py - About 4 hrs to fix

    Function saveXML has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def saveXML( self ):
            """Saves the XML info to a file in a JUnit style."""
            try:
                if self.useXML == True:
                    if self.xmlFile is not None:
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec/xmlout.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, name, classname, pTime=None, stdout=None, stderr=None, tcType=None, message=None, output=None):
    Severity: Major
    Found in vector-uefi/fd/tool/chipsec/xmlout.py - About 1 hr to fix

      Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, name, test_cases, hostname, ts_id, package, timestamp, properties):
      Severity: Major
      Found in vector-uefi/fd/tool/chipsec/xmlout.py - About 50 mins to fix

        Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, name, test_cases=None, hostname=None, ts_id=None, package=None, timestamp=None, properties=None):
        Severity: Major
        Found in vector-uefi/fd/tool/chipsec/xmlout.py - About 50 mins to fix

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

              def add_skipped_info(self, message=None, output=None):
                  """Sets the values for the corresponding Type Skipped."""
                  self.tcType          = testCaseType.SKIPPED
                  self.tcMessage       = message
                  self.tcOutput        = output
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 2 hrs to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 228..235
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 237..244

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

          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

                      elif tc.is_error():
                          error_element = ET.SubElement( tc_element, "error", {'type': 'error'} )
                          if tc.error_message:
                              error_element.set( 'message', tc.error_message )
                          if tc.error_output:
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 2 hrs to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 395..400
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 407..412

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

          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 add_failure_info(self, message=None, output=None):
                  """Sets the values for the corresponding Type Failure."""
                  self.tcType          = testCaseType.FAILURE
                  self.tcMessage       = message
                  self.tcOutput        = output
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 2 hrs to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 237..244
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 246..253

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

          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

                      elif tc.is_skipped():
                          skipped_element = ET.SubElement( tc_element, "skipped", {'type': 'skipped'} )
                          if tc.skipped_message:
                              skipped_element.set( 'message', tc.skipped_message )
                          if tc.skipped_output:
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 2 hrs to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 395..400
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 401..406

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

          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 add_error_info(self, message=None, output=None):
                  """Sets the values for the corresponding Type Error."""
                  self.tcType        = testCaseType.ERROR
                  self.tcMessage     = message
                  self.tcOutput      = output
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 2 hrs to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 228..235
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 246..253

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

          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

                      elif tc.is_failure():
                          failure_element = ET.SubElement( tc_element, "failure", {'type': 'failure'} )
                          if tc.failure_message:
                              failure_element.set( 'message', tc.failure_message )
                          if tc.failure_output:
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 2 hrs to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 401..406
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 407..412

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

          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 failed_check(self, text):
                  """Used when you want to mark a testcase as FAILURE and add it to the testsuite."""
                  if self.useXML == True:
                      self._check_testCase_exist()
                      self.testCase.add_failure_info( text, None )
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 1 hr to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 92..97
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 99..104

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

          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 skipped_check(self, text):
                  """Used when you want to mark a testcase as SKIPPED and add it to the testsuite."""
                  if self.useXML == True:
                      self._check_testCase_exist()
                      self.testCase.add_skipped_info( text, None )
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 1 hr to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 85..90
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 92..97

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

          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 error_check(self, text):
                  """Used when you want to mark a testcase as ERROR and add it to the testsuite."""
                  if self.useXML == True:
                      self._check_testCase_exist()
                      self.testCase.add_error_info( text, None )
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 1 hr to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 85..90
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 99..104

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

          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

              def add_stderr_info(self, text):
                  """Adds the text that is going to be part of the stderr for the TestCase."""
                  if self.stderr is not None:
                      self.stderr += str(text)
                  else:
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 1 other location - About 1 hr to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 255..260

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

          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

              def add_stdout_info(self, text):
                  """Adds the text that is going to be part of the stdout for the TestCase."""
                  if self.stdout is not None:
                      self.stdout += str(text)
                  else:
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 1 other location - About 1 hr to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 262..267

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

          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

                  ts_attributes['failures']      = str( len( [tc for tc in self.test_cases if tc.is_failure()] ) )
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 45 mins to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 366..366
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 367..367

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

          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

                  ts_attributes['errors']        = str( len( [tc for tc in self.test_cases if tc.is_error()] ) )
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 45 mins to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 365..365
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 367..367

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

          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

                  ts_attributes['skipped']       = str( len( [tc for tc in self.test_cases if tc.is_skipped()] ) )
          Severity: Major
          Found in vector-uefi/fd/tool/chipsec/xmlout.py and 2 other locations - About 45 mins to fix
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 365..365
          vector-uefi/fd/tool/chipsec/xmlout.py on lines 366..366

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

          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