hackedteam/vector-edk

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

Summary

Maintainability
C
1 day
Test Coverage

OsHelper has 34 functions (exceeds 20 allowed). Consider refactoring.
Open

class OsHelper:
    def __init__(self):
        self.helper = None
        self.loadHelpers()
        #print "Operating System: %s %s %s %s" % (self.os_system, self.os_release, self.os_version, self.os_machine)
Severity: Minor
Found in vector-uefi/fd/tool/chipsec/helper/oshelper.py - About 4 hrs to fix

    Function loadHelpersFromFileSystem has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def loadHelpersFromFileSystem(self):
            mydir = os.path.dirname(__file__)
            dirs = os.listdir(mydir)
            for adir in dirs:
                if self.helper :
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec/helper/oshelper.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 send_sw_smi has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def send_sw_smi( self, SMI_code_data, _rax, _rbx, _rcx, _rdx, _rsi, _rdi ):
    Severity: Major
    Found in vector-uefi/fd/tool/chipsec/helper/oshelper.py - About 50 mins to fix

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

          def do_hypercall( self, vector, arg1=0, arg2=0, arg3=0, arg4=0, arg5=0, use_peach=0 ):
      Severity: Major
      Found in vector-uefi/fd/tool/chipsec/helper/oshelper.py - About 50 mins to fix

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

            def write_pci_reg( self, bus, device, function, address, value, size ):
        Severity: Minor
        Found in vector-uefi/fd/tool/chipsec/helper/oshelper.py - About 45 mins to fix

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

              def read_pci_reg( self, bus, device, function, address, size ):
          Severity: Minor
          Found in vector-uefi/fd/tool/chipsec/helper/oshelper.py - About 35 mins to fix

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

                    if ( 0 != (address & (size - 1)) ):
                        logger().warn( "Config register address is not naturally aligned" )
            Severity: Minor
            Found in vector-uefi/fd/tool/chipsec/helper/oshelper.py and 1 other location - About 35 mins to fix
            vector-uefi/fd/tool/chipsec/helper/oshelper.py on lines 183..184

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

            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 ( 0 != (address & (size - 1)) ):
                        logger().warn( "Config register address is not naturally aligned" )
            Severity: Minor
            Found in vector-uefi/fd/tool/chipsec/helper/oshelper.py and 1 other location - About 35 mins to fix
            vector-uefi/fd/tool/chipsec/helper/oshelper.py on lines 188..189

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

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

            def f_mod_zip(x):
                return ( x.find('__init__') == -1 and ZIP_HELPER_RE.match(x) )
            Severity: Major
            Found in vector-uefi/fd/tool/chipsec/helper/oshelper.py and 9 other locations - About 30 mins to fix
            vector-uefi/fd/tool/chipsec_main.py on lines 88..89
            vector-uefi/fd/tool/chipsec_util.py on lines 66..67
            vector-uefi/fd/tool/chipsec_util.py on lines 72..73
            vector-uefi/fd/tool/flash.py on lines 73..74
            vector-uefi/fd/tool/flash.py on lines 79..80
            vector-uefi/fd/tool/patch.py on lines 73..74
            vector-uefi/fd/tool/patch.py on lines 79..80
            vector-uefi/fd/tool/test.py on lines 73..74
            vector-uefi/fd/tool/test.py on lines 79..80

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

            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