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 |
||
10 | class ComposeManagerRemoveTest extends PHPUnit_Framework_TestCase |
||
11 | { |
||
12 | public function setUp() |
||
18 | |||
19 | /** |
||
20 | * Test remove whithout error |
||
21 | */ |
||
22 | public function testRemove() |
||
27 | |||
28 | /** |
||
29 | * Test remove force |
||
30 | */ |
||
31 | public function testRemoveForce() |
||
36 | |||
37 | /** |
||
38 | * Test remove volumes |
||
39 | */ |
||
40 | public function testRemoveVolumes() |
||
45 | |||
46 | /** |
||
47 | * Test remove force and volumes |
||
48 | */ |
||
49 | public function testRemoveForceAndVolumes() |
||
54 | |||
55 | /** |
||
56 | * Test remove success with one compose file |
||
57 | */ |
||
58 | public function testRemoveWithOneComposeFileSpecified() |
||
64 | |||
65 | /** |
||
66 | * Test remove success with two compose files |
||
67 | */ |
||
68 | public function testRemoveWithTwoComposeFilesSpecified() |
||
74 | |||
75 | /** |
||
76 | * Test remove with ComposeFileNotFoundException |
||
77 | * |
||
78 | * @expectedException \DockerCompose\Exception\ComposeFileNotFoundException |
||
79 | */ |
||
80 | View Code Duplication | public function testRemoveThrowComposeFileNotFound() |
|
87 | |||
88 | /** |
||
89 | * Test remove with DockerHostConnexionErrorException |
||
90 | * |
||
91 | * @expectedException \DockerCompose\Exception\DockerHostConnexionErrorException |
||
92 | */ |
||
93 | View Code Duplication | public function testRemoveThrowDockerHostConnexionErrorException() |
|
100 | |||
101 | /** |
||
102 | * Test remove with DockerInstallationMissingException |
||
103 | * |
||
104 | * @expectedException \DockerCompose\Exception\DockerInstallationMissingException |
||
105 | */ |
||
106 | public function testRemoveThrowDockerInstallationMissingException() |
||
111 | } |
||
112 |
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.