hackedteam/vector-edk

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

Summary

Maintainability
D
2 days
Test Coverage

Function get_device_bars has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def get_device_bars( self, bus, dev, fun ):
        _bars = []
        off = 0x10
        while (off < 0x28):
            base_lo = self.read_dword( bus, dev, fun, off )
Severity: Minor
Found in vector-uefi/fd/tool/chipsec/hal/pci.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 enumerate_devices has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def enumerate_devices( self ):
        devices = []
        for b in range(256):
            for d in range(32):
                for f in range(8):
Severity: Minor
Found in vector-uefi/fd/tool/chipsec/hal/pci.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 write_dword has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def write_dword( self, bus, device, function, address, dword_value ):
Severity: Minor
Found in vector-uefi/fd/tool/chipsec/hal/pci.py - About 35 mins to fix

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

        def write_byte(self, bus, device, function, address, byte_value ):
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec/hal/pci.py - About 35 mins to fix

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

          def write_word(self, bus, device, function, address, word_value ):
      Severity: Minor
      Found in vector-uefi/fd/tool/chipsec/hal/pci.py - About 35 mins to fix

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

            def read_dword(self, bus, device, function, address ):
                value = self.helper.read_pci_reg( bus, device, function, address, 4 )
                if logger().VERBOSE:
                  logger().log( "[pci] reading B/D/F: %d/%d/%d, offset: 0x%02X, value: 0x%08X" % (bus, device, function, address, value) )
                return value
        Severity: Major
        Found in vector-uefi/fd/tool/chipsec/hal/pci.py and 2 other locations - About 2 hrs to fix
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 91..95
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 97..101

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

        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 read_word(self, bus, device, function, address ):
                word_value = self.helper.read_pci_reg( bus, device, function, address, 2 )
                if logger().VERBOSE:
                  logger().log( "[pci] reading B/D/F: %d/%d/%d, offset: 0x%02X, value: 0x%04X" % (bus, device, function, address, word_value) )
                return word_value
        Severity: Major
        Found in vector-uefi/fd/tool/chipsec/hal/pci.py and 2 other locations - About 2 hrs to fix
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 85..89
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 97..101

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

        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 read_byte(self, bus, device, function, address ):
                byte_value = self.helper.read_pci_reg( bus, device, function, address, 1 )
                if logger().VERBOSE:
                  logger().log( "[pci] reading B/D/F: %d/%d/%d, offset: 0x%02X, value: 0x%02X" % (bus, device, function, address, byte_value) )
                return byte_value
        Severity: Major
        Found in vector-uefi/fd/tool/chipsec/hal/pci.py and 2 other locations - About 2 hrs to fix
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 85..89
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 91..95

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

        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 write_dword( self, bus, device, function, address, dword_value ):
                self.helper.write_pci_reg( bus, device, function, address, dword_value, 4 )
                if logger().VERBOSE:
                  logger().log( "[pci] writing B/D/F: %d/%d/%d, offset: 0x%02X, value: 0x%08X" % (bus, device, function, address, dword_value) )
                return
        Severity: Major
        Found in vector-uefi/fd/tool/chipsec/hal/pci.py and 2 other locations - About 2 hrs to fix
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 104..108
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 110..114

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

        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 write_byte(self, bus, device, function, address, byte_value ):
                self.helper.write_pci_reg( bus, device, function, address, byte_value, 1 )
                if logger().VERBOSE:
                  logger().log( "[pci] writing B/D/F: %d/%d/%d, offset: 0x%02X, value: 0x%02X" % (bus, device, function, address, byte_value) )
                return
        Severity: Major
        Found in vector-uefi/fd/tool/chipsec/hal/pci.py and 2 other locations - About 2 hrs to fix
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 110..114
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 116..120

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

        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 write_word(self, bus, device, function, address, word_value ):
                self.helper.write_pci_reg( bus, device, function, address, word_value, 2 )
                if logger().VERBOSE:
                  logger().log( "[pci] writing B/D/F: %d/%d/%d, offset: 0x%02X, value: 0x%04X" % (bus, device, function, address, word_value) )
                return
        Severity: Major
        Found in vector-uefi/fd/tool/chipsec/hal/pci.py and 2 other locations - About 2 hrs to fix
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 104..108
        vector-uefi/fd/tool/chipsec/hal/pci.py on lines 116..120

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

        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