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 |
||
8 | class FacadeTest extends \Codeception\Test\Unit |
||
9 | { |
||
10 | /** |
||
11 | * @var \Nexus\CustomCommand\CustomCommandFacade |
||
12 | */ |
||
13 | private $facade; |
||
14 | |||
15 | protected function _before() |
||
19 | |||
20 | /** |
||
21 | * @group Nexus |
||
22 | * @group CustomCommand |
||
23 | * @group Facade |
||
24 | * @group Integration |
||
25 | */ |
||
26 | View Code Duplication | public function testHydrateCommandsRecusive() |
|
41 | |||
42 | /** |
||
43 | * @group Nexus |
||
44 | * @group CustomCommand |
||
45 | * @group Facade |
||
46 | * @group Integration |
||
47 | */ |
||
48 | View Code Duplication | public function testHydrateCommandsNotRecusive() |
|
59 | |||
60 | /** |
||
61 | * @group Nexus |
||
62 | * @group CustomCommand |
||
63 | * @group Facade |
||
64 | * @group Integration |
||
65 | */ |
||
66 | public function testHydrateCommandsWithNonExistingDirectory() |
||
72 | } |
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.