hackedteam/vector-edk

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

Summary

Maintainability
D
2 days
Test Coverage

File uefi_common.py has 457 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/hal/uefi_common.py - About 7 hrs to fix

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

    def parse_db( db, decode_dir ):
       db_size = len(db)
       if 0 == db_size:
           return
       dof = 0
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec/hal/uefi_common.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 NextFwFile has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def NextFwFile(FvImage, FvLength, fof, polarity):
        EFI_FFS_FILE_HEADER = "<IHH8sHBB3sB"
        file_header_size = struct.calcsize(EFI_FFS_FILE_HEADER)
        fof = align(fof, 8)
        cur_offset = fof
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec/hal/uefi_common.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 NextFwFileSection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def NextFwFileSection(sections, ssize, sof, polarity):
      # offset, next_offset, SecName, SecType, SecBody, SecHeaderSize
      cur_offset = sof
      if (sof + EFI_COMMON_SECTION_HEADER_size) < ssize:
        header = sections[sof:sof+EFI_COMMON_SECTION_HEADER_size]
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec/hal/uefi_common.py - About 55 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

      return (ord(s[0]) + (ord(s[1]) << 8) + (ord(s[2]) << 16))
    Severity: Major
    Found in vector-uefi/fd/tool/chipsec/hal/uefi_common.py and 1 other location - About 2 hrs to fix
    AppPkg/Applications/Python/Python-2.7.2/Tools/scripts/checkpyc.py on lines 63..63

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

    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

      guid = "%08X-%04X-%04X-%04s-%06s" % (guid0, guid1, guid2, guid3[:2].encode('hex').upper(), guid3[-6::].encode('hex').upper())
    Severity: Major
    Found in vector-uefi/fd/tool/chipsec/hal/uefi_common.py and 1 other location - About 1 hr to fix
    vector-uefi/fd/tool/chipsec/helper/win/win32helper.py on lines 163..163

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

    SECTION_NAMES = {0x00: 'S_ALL', 0x01: 'S_COMPRESSION', 0x02: 'S_GUID_DEFINED', 0x10: 'S_PE32', 0x11: 'S_PIC', 0x12: 'S_TE', 0x13: 'S_DXE_DEPEX', 0x14: 'S_VERSION', 0x15: 'S_USER_INTERFACE', 0x16: 'S_COMPATIBILITY16', 0x17: 'S_FV_IMAGE', 0x18: 'S_FREEFORM_SUBTYPE_GUID', 0x19: 'S_RAW', 0x1B: 'S_PEI_DEPEX', 0x1C: 'S_SMM_DEPEX'}
    Severity: Major
    Found in vector-uefi/fd/tool/chipsec/hal/uefi_common.py and 5 other locations - About 35 mins to fix
    vector-uefi/fd/tool/chipsec/hal/pcidb.py on lines 3949..3963
    vector-uefi/fd/tool/chipsec/hal/pcidb.py on lines 4434..4448
    vector-uefi/fd/tool/chipsec/hal/pcidb.py on lines 6840..6854
    vector-uefi/fd/tool/chipsec/hal/pcidb.py on lines 7370..7384
    vector-uefi/fd/tool/chipsec/hal/pcidb.py on lines 8264..8278

    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

    There are no issues that match your filters.

    Category
    Status