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 ComposeManagerTest extends PHPUnit_Framework_TestCase |
||
11 | { |
||
12 | public function setUp() |
||
18 | |||
19 | /** |
||
20 | * Test stop whithout error |
||
21 | */ |
||
22 | public function testStop() |
||
27 | |||
28 | /** |
||
29 | * Test stop success with one compose file |
||
30 | */ |
||
31 | public function testStopWithOneComposeFileSpecified() |
||
37 | |||
38 | /** |
||
39 | * Test stop success with two compose files |
||
40 | */ |
||
41 | public function testStopWithTwoComposeFilesSpecified() |
||
47 | |||
48 | /** |
||
49 | * Test stop with ComposeFileNotFoundException |
||
50 | * |
||
51 | * @expectedException \DockerCompose\Exception\ComposeFileNotFoundException |
||
52 | */ |
||
53 | View Code Duplication | public function testStopThrowComposeFileNotFound() |
|
60 | |||
61 | /** |
||
62 | * Test stop with DockerHostConnexionErrorException |
||
63 | * |
||
64 | * @expectedException \DockerCompose\Exception\DockerHostConnexionErrorException |
||
65 | */ |
||
66 | View Code Duplication | public function testStopThrowDockerHostConnexionErrorException() |
|
73 | |||
74 | /** |
||
75 | * Test stop with DockerInstallationMissingException |
||
76 | * |
||
77 | * @expectedException \DockerCompose\Exception\DockerInstallationMissingException |
||
78 | */ |
||
79 | public function testStopThrowDockerInstallationMissingException() |
||
84 | } |
||
85 |
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.