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 |
||
17 | class KoalamonSummaryReporter implements Reporter |
||
18 | { |
||
19 | private $failed = 0; |
||
20 | private $success = 0; |
||
21 | |||
22 | /** |
||
23 | * @var Configuration |
||
24 | */ |
||
25 | private $config; |
||
26 | private $system; |
||
27 | private $identifier; |
||
28 | private $tool = 'smoke'; |
||
29 | private $server; |
||
30 | private $url; |
||
31 | |||
32 | /** |
||
33 | * @var KoalaReporter |
||
34 | */ |
||
35 | private $reporter; |
||
36 | |||
37 | /** |
||
38 | * @var Retriever |
||
39 | */ |
||
40 | private $retriever; |
||
|
|||
41 | |||
42 | /** |
||
43 | * @var OutputInterface |
||
44 | */ |
||
45 | private $output; |
||
46 | |||
47 | /** |
||
48 | * @var LeankoalaExtension |
||
49 | */ |
||
50 | private $leankoalaExtension; |
||
51 | |||
52 | const STATUS_SUCCESS = 'success'; |
||
53 | const STATUS_FAILURE = 'failure'; |
||
54 | |||
55 | public function init($apiKey, Configuration $_configuration, OutputInterface $_output, $server = 'https://webhook.koalamon.com', $system = '', $identifier = '', $tool = '', $url ='') |
||
78 | |||
79 | /** |
||
80 | * @param CheckResult[] $results |
||
81 | */ |
||
82 | public function processResults($results) |
||
92 | |||
93 | public function finish() |
||
107 | |||
108 | /** |
||
109 | * @param $identifier |
||
110 | * @param $system |
||
111 | * @param $message |
||
112 | * @param $status |
||
113 | * @param $value |
||
114 | * @param $tool |
||
115 | * @param $component |
||
116 | * @param Attribute[] $attributes |
||
117 | */ |
||
118 | View Code Duplication | private function send($identifier, $system, $message, $status, $value, $tool, $component, $attributes = [], $url = "") |
|
140 | } |
||
141 |
This check marks private properties in classes that are never used. Those properties can be removed.