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 |
||
| 9 | class CrudPanelCreateTest extends BaseDBCrudPanelTest |
||
| 10 | { |
||
| 11 | private $nonRelationshipField = [ |
||
| 12 | 'name' => 'field1', |
||
| 13 | 'label' => 'Field1', |
||
| 14 | ]; |
||
| 15 | |||
| 16 | private $userInputFieldsNoRelationships = [ |
||
| 17 | [ |
||
| 18 | 'name' => 'id', |
||
| 19 | 'type' => 'hidden', |
||
| 20 | ], [ |
||
| 21 | 'name' => 'name', |
||
| 22 | ], [ |
||
| 23 | 'name' => 'email', |
||
| 24 | 'type' => 'email', |
||
| 25 | ], [ |
||
| 26 | 'name' => 'password', |
||
| 27 | 'type' => 'password', |
||
| 28 | ], |
||
| 29 | ]; |
||
| 30 | |||
| 31 | private $articleInputFieldsOneToMany = [ |
||
| 32 | [ |
||
| 33 | 'name' => 'id', |
||
| 34 | 'type' => 'hidden', |
||
| 35 | ], [ |
||
| 36 | 'name' => 'content', |
||
| 37 | ], [ |
||
| 38 | 'name' => 'tags', |
||
| 39 | ], [ |
||
| 40 | 'label' => 'Author', |
||
| 41 | 'type' => 'select', |
||
| 42 | 'name' => 'user_id', |
||
| 43 | 'entity' => 'user', |
||
| 44 | 'attribute' => 'name', |
||
| 45 | ], |
||
| 46 | ]; |
||
| 47 | |||
| 48 | private $userInputFieldsManyToMany = [ |
||
| 49 | [ |
||
| 50 | 'name' => 'id', |
||
| 51 | 'type' => 'hidden', |
||
| 52 | ], [ |
||
| 53 | 'name' => 'name', |
||
| 54 | ], [ |
||
| 55 | 'name' => 'email', |
||
| 56 | 'type' => 'email', |
||
| 57 | ], [ |
||
| 58 | 'name' => 'password', |
||
| 59 | 'type' => 'password', |
||
| 60 | ], [ |
||
| 61 | 'label' => 'Roles', |
||
| 62 | 'type' => 'select_multiple', |
||
| 63 | 'name' => 'roles', |
||
| 64 | 'entity' => 'roles', |
||
| 65 | 'attribute' => 'name', |
||
| 66 | 'pivot' => true, |
||
| 67 | ], |
||
| 68 | ]; |
||
| 69 | |||
| 70 | private $userInputFieldsDotNotation = [ |
||
| 71 | [ |
||
| 72 | 'name' => 'id', |
||
| 73 | 'type' => 'hidden', |
||
| 74 | ], [ |
||
| 75 | 'name' => 'name', |
||
| 76 | ], [ |
||
| 77 | 'name' => 'email', |
||
| 78 | 'type' => 'email', |
||
| 79 | ], [ |
||
| 80 | 'name' => 'password', |
||
| 81 | 'type' => 'password', |
||
| 82 | ], [ |
||
| 83 | 'label' => 'Roles', |
||
| 84 | 'type' => 'select_multiple', |
||
| 85 | 'name' => 'roles', |
||
| 86 | 'entity' => 'roles', |
||
| 87 | 'attribute' => 'name', |
||
| 88 | 'pivot' => true, |
||
| 89 | ], [ |
||
| 90 | 'label' => 'Street', |
||
| 91 | 'name' => 'street', |
||
| 92 | 'entity' => 'accountDetails.addresses', |
||
| 93 | 'attribute' => 'street', |
||
| 94 | ], |
||
| 95 | ]; |
||
| 96 | |||
| 97 | private $userInputFieldsManyToOne = [ |
||
| 98 | [ |
||
| 99 | 'name' => 'id', |
||
| 100 | 'type' => 'hidden', |
||
| 101 | ], [ |
||
| 102 | 'name' => 'name', |
||
| 103 | ], [ |
||
| 104 | 'name' => 'email', |
||
| 105 | 'type' => 'email', |
||
| 106 | ], [ |
||
| 107 | 'name' => 'password', |
||
| 108 | 'type' => 'password', |
||
| 109 | ], [ |
||
| 110 | 'name' => 'articles', |
||
| 111 | 'type' => 'select2_many', |
||
| 112 | 'entity' => 'articles', |
||
| 113 | 'attribute' => 'content', |
||
| 114 | ], |
||
| 115 | ]; |
||
| 116 | |||
| 117 | public function testCreate() |
||
| 134 | |||
| 135 | public function testCreateWithOneToOneRelationship() |
||
| 139 | |||
| 140 | public function testCreateWithOneToManyRelationship() |
||
| 163 | |||
| 164 | public function testCreateWithManyToOneRelationship() |
||
| 183 | |||
| 184 | public function testCreateWithManyToManyRelationship() |
||
| 202 | |||
| 203 | View Code Duplication | public function testGetRelationFields() |
|
| 216 | |||
| 217 | View Code Duplication | public function testGetRelationFieldsCreateForm() |
|
| 226 | |||
| 227 | View Code Duplication | public function testGetRelationFieldsUpdateForm() |
|
| 236 | |||
| 237 | public function testGetRelationFieldsUnknownForm() |
||
| 250 | |||
| 251 | View Code Duplication | public function testGetRelationFieldsDotNotation() |
|
| 260 | |||
| 261 | public function testGetRelationFieldsNoRelations() |
||
| 269 | |||
| 270 | public function testGetRelationFieldsNoFields() |
||
| 276 | |||
| 277 | View Code Duplication | public function testGetRelationFieldsWithPivot() |
|
| 286 | |||
| 287 | public function testGetRelationFieldsWithPivotNoRelations() |
||
| 296 | |||
| 297 | View Code Duplication | public function testSyncPivot() |
|
| 315 | |||
| 316 | View Code Duplication | public function testSyncPivotUnknownData() |
|
| 334 | |||
| 335 | View Code Duplication | public function testSyncPivotUnknownModel() |
|
| 353 | } |
||
| 354 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.