Skip to content

badblocks.c from rufus#17

Open
pavel-ignatovich wants to merge 1 commit intomasterfrom
c_rufus_badblocks.c
Open

badblocks.c from rufus#17
pavel-ignatovich wants to merge 1 commit intomasterfrom
c_rufus_badblocks.c

Conversation

@pavel-ignatovich
Copy link
Copy Markdown

Copy link
Copy Markdown

@monocodus monocodus Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is autogenerated code-style review, new suggestions: 6

Comment thread badblocks.c
{
if (bb_u64_list_find(bb, blk) < 0)
return 0;
else
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else

This comment was generated with the following checker: ClangTidy

Comment thread badblocks.c
return got;
}

static unsigned int test_rw(HANDLE hDrive, blk64_t last_block, size_t block_size, blk64_t first_block,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread badblocks.c
/*
* This procedure adds a block to a badblocks list.
*/
static errcode_t bb_u64_list_add(bb_u64_list bb, uint64_t blk)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread badblocks.c
return got;
}

static unsigned int test_rw(HANDLE hDrive, blk64_t last_block, size_t block_size, blk64_t first_block,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread badblocks.c
return got;
}

static unsigned int test_rw(HANDLE hDrive, blk64_t last_block, size_t block_size, blk64_t first_block,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread badblocks.c
return bb_count;
}

BOOL BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int nb_passes,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C/C++ Files in C or C++ Demonstration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant