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 | class ContentItem extends PermalinkFrontMatterDocument implements CollectableItem, TemplateReadyDocument |
||
| 17 | { |
||
| 18 | use CollectableItemTrait; |
||
| 19 | use TemplateEngineDependent; |
||
| 20 | |||
| 21 | /// |
||
| 22 | // Permalink management |
||
| 23 | /// |
||
| 24 | |||
| 25 | /** |
||
| 26 | * {@inheritdoc} |
||
| 27 | */ |
||
| 28 | 1 | public function handleSpecialRedirects() |
|
| 44 | |||
| 45 | /// |
||
| 46 | // Document body transformation |
||
| 47 | /// |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @throws TemplateErrorInterface |
||
| 51 | * |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | 7 | public function getContent() |
|
| 66 | |||
| 67 | /** |
||
| 68 | * Transform the document's body from a markup language to HTML. |
||
| 69 | * |
||
| 70 | * @todo Port this to follow the same pattern as the template engine |
||
| 71 | */ |
||
| 72 | 7 | private function parseMarkupLanguage() |
|
| 93 | |||
| 94 | /** |
||
| 95 | * {@inheritdoc} |
||
| 96 | */ |
||
| 97 | 25 | View Code Duplication | public function createJail() |
| 109 | |||
| 110 | /** |
||
| 111 | * {@inheritdoc} |
||
| 112 | */ |
||
| 113 | View Code Duplication | public function jsonSerialize() |
|
| 121 | } |
||
| 122 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.