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 MarathonAppEntity implements JobEntityInterface |
||
| 20 | { |
||
| 21 | public $id = ''; |
||
| 22 | |||
| 23 | public $cmd = null; |
||
| 24 | |||
| 25 | public $cpus = 0; |
||
| 26 | |||
| 27 | public $mem = 0; |
||
| 28 | |||
| 29 | public $args = null; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var PortDefinition[] |
||
| 33 | */ |
||
| 34 | public $portDefinitions = null; |
||
| 35 | |||
| 36 | public $requirePorts = false; |
||
| 37 | |||
| 38 | public $instances = 0; |
||
| 39 | |||
| 40 | public $executor = ''; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var Container |
||
| 44 | */ |
||
| 45 | public $container = null; |
||
| 46 | |||
| 47 | public $env = null; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var array |
||
| 51 | */ |
||
| 52 | public $constraints = []; |
||
| 53 | |||
| 54 | |||
| 55 | public $acceptedResourceRoles = null; |
||
| 56 | |||
| 57 | public $labels = null; |
||
| 58 | |||
| 59 | public $uris = []; |
||
| 60 | |||
| 61 | public $dependencies = []; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var HealthCheck[] |
||
| 65 | */ |
||
| 66 | public $healthChecks = null; |
||
| 67 | |||
| 68 | public $backoffSeconds = 1; |
||
| 69 | |||
| 70 | public $backoffFactor = 1.15; |
||
| 71 | |||
| 72 | public $maxLaunchDelaySeconds = 3600; |
||
| 73 | |||
| 74 | public $taskKillGracePeriodSeconds = 0; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @var UpgradeStrategy |
||
| 78 | */ |
||
| 79 | public $upgradeStrategy = null; |
||
| 80 | |||
| 81 | |||
| 82 | /** |
||
| 83 | * @var IpAddress |
||
| 84 | */ |
||
| 85 | public $ipAddress = null; |
||
| 86 | |||
| 87 | 48 | public function __construct($data = null) |
|
| 147 | 4 | ||
| 148 | /** |
||
| 149 | 4 | * @inheritdoc |
|
| 150 | 4 | * @return array |
|
| 151 | */ |
||
| 152 | 4 | View Code Duplication | public function jsonSerialize() |
| 164 | 4 | ||
| 165 | /** |
||
| 166 | 4 | * @inheritdoc |
|
| 167 | * @return \ArrayIterator |
||
| 168 | */ |
||
| 169 | public function getIterator() |
||
| 173 | 4 | ||
| 174 | /** |
||
| 175 | 4 | * @inheritdoc |
|
| 176 | * @return array |
||
| 177 | 4 | */ |
|
| 178 | 4 | public function getSimpleArrayCopy() |
|
| 188 | |||
| 189 | /** |
||
| 190 | * @inheritdoc |
||
| 191 | * @return bool |
||
| 192 | */ |
||
| 193 | public function isSchedulingJob() |
||
| 197 | 5 | ||
| 198 | /** |
||
| 199 | 5 | * @inheritdoc |
|
| 200 | * @return bool |
||
| 201 | */ |
||
| 202 | public function isDependencyJob() |
||
| 206 | |||
| 207 | 5 | /** |
|
| 208 | * @return string |
||
| 209 | */ |
||
| 210 | public function getEntityType() |
||
| 214 | |||
| 215 | 27 | /** |
|
| 216 | * @return string |
||
| 217 | */ |
||
| 218 | public function getKey() |
||
| 222 | } |
||
| 223 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.