badblocks.c from rufus#17
Conversation
| { | ||
| if (bb_u64_list_find(bb, blk) < 0) | ||
| return 0; | ||
| else |
There was a problem hiding this comment.
| else | |
This comment was generated with the following checker: ClangTidy
| return got; | ||
| } | ||
|
|
||
| static unsigned int test_rw(HANDLE hDrive, blk64_t last_block, size_t block_size, blk64_t first_block, |
There was a problem hiding this comment.
The function is too long
test_rw( HANDLE hDrive , blk64_t last_block , size_t block_size , blk64_t first_block , size_t blocks_at_once , int pattern_type , int nb_passes) now spans 140 lines.
Corresponding modifications started here.
Keep your functions' length within 50 lines to improve readability.
This comment was generated with the following checker: long_method
| /* | ||
| * This procedure adds a block to a badblocks list. | ||
| */ | ||
| static errcode_t bb_u64_list_add(bb_u64_list bb, uint64_t blk) |
There was a problem hiding this comment.
The function is too complicated
bb_u64_list_add( bb_u64_list bb , uint64_t blk) now has cyclomatic complexity of 11.
Corresponding modifications started here.
Split your routines to keep cyclomatic complexity below 10 to improve their maintainability.
This comment was generated with the following checker: high_cyclomatic_complexity
| return got; | ||
| } | ||
|
|
||
| static unsigned int test_rw(HANDLE hDrive, blk64_t last_block, size_t block_size, blk64_t first_block, |
There was a problem hiding this comment.
The function is too complicated
test_rw( HANDLE hDrive , blk64_t last_block , size_t block_size , blk64_t first_block , size_t blocks_at_once , int pattern_type , int nb_passes) now has cyclomatic complexity of 46.
Corresponding modifications started here.
Split your routines to keep cyclomatic complexity below 10 to improve their maintainability.
This comment was generated with the following checker: high_cyclomatic_complexity
| return got; | ||
| } | ||
|
|
||
| static unsigned int test_rw(HANDLE hDrive, blk64_t last_block, size_t block_size, blk64_t first_block, |
There was a problem hiding this comment.
The function has too many parameters
test_rw( HANDLE hDrive , blk64_t last_block , size_t block_size , blk64_t first_block , size_t blocks_at_once , int pattern_type , int nb_passes) now has 7 parameters.
Functions with parameter list length above 5 are mostly hard to understand and use.
To reduce the number of arguments, you can isolate arguments used together into an object, or split the function
This comment was generated with the following checker: long_parameter_list
| return bb_count; | ||
| } | ||
|
|
||
| BOOL BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int nb_passes, |
There was a problem hiding this comment.
The function has too many parameters
BadBlocks( HANDLE hPhysicalDrive , ULONGLONG disk_size , int nb_passes , int flash_type , badblocks_report * report , FILE * fd) now has 6 parameters.
Functions with parameter list length above 5 are mostly hard to understand and use.
To reduce the number of arguments, you can isolate arguments used together into an object, or split the function
This comment was generated with the following checker: long_parameter_list
src/badblocks.c from https://github.com/pbatard/rufus/blob/cda716c/src/badblocks.c