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 |
||
19 | class Lint extends Process |
||
20 | { |
||
21 | /** |
||
22 | * @return bool |
||
23 | */ |
||
24 | View Code Duplication | public function hasSyntaxError() |
|
34 | |||
35 | /** |
||
36 | * @return bool|array |
||
37 | */ |
||
38 | View Code Duplication | public function getSyntaxError() |
|
48 | |||
49 | /** |
||
50 | * Parse error message. |
||
51 | * |
||
52 | * @param string $message |
||
53 | * |
||
54 | * @return array |
||
55 | */ |
||
56 | View Code Duplication | public function parseError($message) |
|
71 | |||
72 | /** |
||
73 | * @return bool |
||
74 | */ |
||
75 | View Code Duplication | public function hasSyntaxIssue() |
|
86 | |||
87 | /** |
||
88 | * @return bool|array |
||
89 | */ |
||
90 | View Code Duplication | public function getSyntaxIssue() |
|
100 | |||
101 | /** |
||
102 | * Parse error message. |
||
103 | * |
||
104 | * @param string $message |
||
105 | * |
||
106 | * @return array |
||
107 | */ |
||
108 | View Code Duplication | private function parseIssue($message) |
|
123 | } |
||
124 |
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.