1.2.1197. Too Long A Block¶
The loop is operating on a block that is too long.
This analysis is applied to loops (for, foreach, while, do..while) and if/then/else/elseif structures.
Then length of a block is managed with the longBlock
parameter. By default, it is 200 lines, from beginning to the end. Comments are taken into account.
<?php
$i = 0;
do {
// 200 lines of PHP code
++$i;
} while($i < 100);
?>
Name |
Default |
Type |
Description |
longBlock |
200 |
integer |
Size of a block for it to be too long. A block is commanded by a for, foreach, while, do…while, if/then else structure. |
1.2.1197.1. Suggestions¶
Move the code of the block to an method or a function
Move part of the code of the block to methods or functions
Extract repeated patterns and use them
1.2.1197.2. Specs¶
Short name |
Structures/LongBlock |
Rulesets |
|
Exakat since |
2.1.2 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Features |
block |
Available in |