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 |
||
| 13 | class SectionTest extends RESTFunctionalTestCase |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Covers GET /content/sections. |
||
| 17 | */ |
||
| 18 | public function testListSections() |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Covers POST /content/sections. |
||
| 29 | * |
||
| 30 | * @return string The created section href |
||
| 31 | */ |
||
| 32 | View Code Duplication | public function testCreateSection() |
|
| 57 | |||
| 58 | /** |
||
| 59 | * @param $sectionHref |
||
| 60 | * @depends testCreateSection |
||
| 61 | * Covers PATCH /content/sections/{sectionId} |
||
| 62 | */ |
||
| 63 | View Code Duplication | public function testUpdateSection($sectionHref) |
|
| 82 | |||
| 83 | /** |
||
| 84 | * Covers GET /content/sections/{sectionId}. |
||
| 85 | * @depends testCreateSection |
||
| 86 | */ |
||
| 87 | public function testLoadSection($sectionHref) |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @depends testCreateSection |
||
| 98 | * Covers GET /content/sections?identifier={sectionIdentifier} |
||
| 99 | */ |
||
| 100 | public function testLoadSectionByIdentifier($sectionHref) |
||
| 108 | |||
| 109 | /** |
||
| 110 | * @depends testCreateSection |
||
| 111 | * Covers DELETE /content/sections/{sectionId} |
||
| 112 | */ |
||
| 113 | public function testDeleteSection($sectionHref) |
||
| 121 | } |
||
| 122 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.