vector-uefi/fd/tool/chipsec/hal/spi_uefi.py
Function parse_uefi_section
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
Open
def parse_uefi_section( _uefi, data, Size, offset, polarity, parent_offset, parent_path, decode_log_path ):
sec_offset, next_sec_offset, SecName, SecType, SecBody, SecHeaderSize = NextFwFileSection(data, Size, offset, polarity)
secn = 0
ui_string = None
efi_file = None
- Read upRead up
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 parse_uefi_region
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
Open
def parse_uefi_region( _uefi, data, uefi_region_path ):
voln = 0
FvOffset, FsGuid, FvLength, FvAttributes, FvHeaderLength, FvChecksum, ExtHeaderOffset, FvImage, CalcSum = NextFwVolume(data)
while FvOffset != None:
decode_log_path = os.path.join(uefi_region_path, "efi_firmware_volumes.log")
- Read upRead up
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 save_file_info
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def save_file_info( cur_offset, Name, Type, Attributes, State, Checksum, Size, file_path, fCalcSum ):
Function save_vol_info
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def save_vol_info( FvOffset, FsGuid, FvLength, FvAttributes, FvHeaderLength, FvChecksum, ExtHeaderOffset, file_path, CalcSum ):
Function parse_uefi_section
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def parse_uefi_section( _uefi, data, Size, offset, polarity, parent_offset, parent_path, decode_log_path ):
Avoid deeply nested control flow statements. Open
Open
if (sguid == EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID):
parse_uefi_section(_uefi, SecBody[DataOffset:], Size - DataOffset, 0, polarity, 0, section_dir_path, decode_log_path)
#else:
# write_file( os.path.join(section_dir_path, "%s-%04X" % (sguid, Attributes)), SecBody[DataOffset:] )
pass
Avoid deeply nested control flow statements. Open
Open
if decompressed:
parse_uefi_section(_uefi, decompressed, len(decompressed), 0, polarity, 0, section_dir_path, decode_log_path)
pass
elif (SecType == EFI_SECTION_GUID_DEFINED):
Avoid deeply nested control flow statements. Open
Open
if os.path.exists( file_path ):
file_path = file_path + ("_%08X" % cur_offset)
write_file( file_path, FileImage )
Avoid deeply nested control flow statements. Open
Open
if Type in FILE_TYPE_NAMES.keys():
file_type_str = FILE_TYPE_NAMES[Type]
file_path = os.path.join( volume_path, "%s.%s-%02X" % (Name, file_type_str, Type))
Avoid deeply nested control flow statements. Open
Open
if (ui_string[-4:] != '.efi'): ui_string = "%s.efi" % ui_string
#print ui_string
Avoid deeply nested control flow statements. Open
Open
if efi_file != None:
os.rename(os.path.join(parent_path, efi_file), os.path.join(parent_path, ui_string))
efi_file = None
if (SecType in (EFI_SECTION_COMPRESSION, EFI_SECTION_GUID_DEFINED, EFI_SECTION_FIRMWARE_VOLUME_IMAGE)):
Avoid deeply nested control flow statements. Open
Open
if (Type not in (EFI_FV_FILETYPE_ALL, EFI_FV_FILETYPE_RAW, EFI_FV_FILETYPE_FFS_PAD)):
os.makedirs( file_dir_path )
parse_uefi_section(_uefi, FileImage, Size, HeaderSize, polarity, FvOffset + cur_offset, file_dir_path, decode_log_path)
elif (Type == EFI_FV_FILETYPE_RAW):
if ((Name == NVAR_NVRAM_FS_FILE) and UD):