We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
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 |
||
11 | class CrudPanelReadTest extends BaseDBCrudPanelTest |
||
12 | { |
||
13 | private $relationshipColumn = [ |
||
14 | 'name' => 'user_id', |
||
15 | 'type' => 'select', |
||
16 | 'entity' => 'user', |
||
17 | 'attribute' => 'name', |
||
18 | ]; |
||
19 | |||
20 | private $nonRelationshipColumn = [ |
||
21 | 'name' => 'field1', |
||
22 | 'label' => 'Field1', |
||
23 | ]; |
||
24 | |||
25 | private $articleFieldsArray = [ |
||
26 | [ |
||
27 | 'name' => 'content', |
||
28 | 'label' => 'The Content', |
||
29 | 'type' => 'text', |
||
30 | ], |
||
31 | [ |
||
32 | 'name' => 'metas', |
||
33 | 'label' => 'Metas', |
||
34 | ], |
||
35 | [ |
||
36 | 'name' => 'tags', |
||
37 | ], |
||
38 | [ |
||
39 | 'name' => 'extras', |
||
40 | ], |
||
41 | ]; |
||
42 | |||
43 | private $expectedCreateFormArticleFieldsArray = [ |
||
44 | 'content' => [ |
||
45 | 'name' => 'content', |
||
46 | 'label' => 'The Content', |
||
47 | 'type' => 'text', |
||
48 | ], |
||
49 | 'metas' => [ |
||
50 | 'name' => 'metas', |
||
51 | 'label' => 'Metas', |
||
52 | 'type' => 'text', |
||
53 | ], |
||
54 | 'tags' => [ |
||
55 | 'name' => 'tags', |
||
56 | 'label' => 'Tags', |
||
57 | 'type' => 'text', |
||
58 | ], |
||
59 | 'extras' => [ |
||
60 | 'name' => 'extras', |
||
61 | 'label' => 'Extras', |
||
62 | 'type' => 'text', |
||
63 | ], |
||
64 | ]; |
||
65 | |||
66 | private $expectedUpdateFormArticleFieldsArray = [ |
||
67 | 'content' => [ |
||
68 | 'name' => 'content', |
||
69 | 'label' => 'The Content', |
||
70 | 'type' => 'text', |
||
71 | 'value' => 'Some Content', |
||
72 | ], |
||
73 | 'metas' => [ |
||
74 | 'name' => 'metas', |
||
75 | 'label' => 'Metas', |
||
76 | 'type' => 'text', |
||
77 | 'value' => '{"meta_title":"Meta Title Value","meta_description":"Meta Description Value"}', |
||
78 | ], |
||
79 | 'tags' => [ |
||
80 | 'name' => 'tags', |
||
81 | 'label' => 'Tags', |
||
82 | 'type' => 'text', |
||
83 | 'value' => '{"tags":["tag1","tag2","tag3"]}', |
||
84 | ], |
||
85 | 'extras' => [ |
||
86 | 'name' => 'extras', |
||
87 | 'label' => 'Extras', |
||
88 | 'type' => 'text', |
||
89 | 'value' => '{"extra_details":["detail1","detail2","detail3"]}', |
||
90 | ], |
||
91 | 'id' => [ |
||
92 | 'name' => 'id', |
||
93 | 'type' => 'hidden', |
||
94 | 'value' => 1, |
||
95 | ], |
||
96 | ]; |
||
97 | |||
98 | private $uploadField = [ |
||
99 | 'name' => 'image', |
||
100 | 'label' => 'Image', |
||
101 | 'type' => 'upload', |
||
102 | 'upload' => true, |
||
103 | ]; |
||
104 | |||
105 | private $multipleUploadField = [ |
||
106 | 'name' => 'photos', |
||
107 | 'label' => 'Photos', |
||
108 | 'type' => 'upload_multiple', |
||
109 | 'upload' => true, |
||
110 | ]; |
||
111 | |||
112 | 1 | View Code Duplication | public function testGetEntry() |
121 | |||
122 | View Code Duplication | public function testGetEntryWithFakes() |
|
138 | |||
139 | 1 | public function testGetEntryExists() |
|
151 | |||
152 | 1 | View Code Duplication | public function testGetEntryUnknownId() |
161 | |||
162 | 1 | public function testAutoEagerLoadRelationshipColumns() |
|
171 | |||
172 | 1 | public function testAutoEagerLoadRelationshipColumnsNoRelationships() |
|
181 | |||
182 | 1 | View Code Duplication | public function testGetEntries() |
192 | |||
193 | View Code Duplication | public function testGetEntriesWithFakes() |
|
207 | |||
208 | 1 | public function testGetFieldsCreateForm() |
|
217 | |||
218 | 1 | public function testGetFieldsUpdateForm() |
|
229 | |||
230 | 1 | public function testGetFieldsUpdateFormUnknownId() |
|
242 | |||
243 | public function testGetFieldsUnknownForm() |
||
255 | |||
256 | 1 | public function testHasUploadFieldsCreateForm() |
|
265 | |||
266 | 1 | public function testHasMultipleUploadFieldsCreateForm() |
|
275 | |||
276 | 1 | View Code Duplication | public function testHasUploadFieldsUpdateForm() |
286 | |||
287 | 1 | View Code Duplication | public function testHasUploadFieldsUpdateFormUnknownId() |
297 | |||
298 | public function testEnableDetailsRow() |
||
304 | |||
305 | public function testDisableDetailsRow() |
||
311 | |||
312 | public function testSetDefaultPageLength() |
||
319 | |||
320 | public function testGetDefaultPageLength() |
||
326 | |||
327 | public function testEnableAjaxTable() |
||
333 | |||
334 | public function testGetAjaxTable() |
||
340 | |||
341 | public function testEnableExportButtons() |
||
347 | |||
348 | public function testGetExportButtons() |
||
354 | } |
||
355 |
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.