Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
16 | View Code Duplication | class CreateTestUsersCommand extends Command |
|
|
|||
17 | { |
||
18 | use TestUsersCommandTrait; |
||
19 | |||
20 | /** |
||
21 | * Configuration for this command. |
||
22 | */ |
||
23 | protected function configure() |
||
34 | |||
35 | /** |
||
36 | * Execute command: create any defined test users on the configured Drush alias. |
||
37 | * |
||
38 | * @todo Codeception debug calls won't work here. |
||
39 | * |
||
40 | * @param InputInterface $input |
||
41 | * The command input. |
||
42 | * |
||
43 | * @param OutputInterface $output |
||
44 | * The command output. |
||
45 | * |
||
46 | * @return int|null|void |
||
47 | * |
||
48 | * @throws ModuleException |
||
49 | */ |
||
50 | protected function execute(InputInterface $input, OutputInterface $output) |
||
61 | } |
||
62 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.