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 |
||
15 | class JsonMatcher implements Context |
||
16 | { |
||
17 | use ApiTrait; |
||
18 | |||
19 | /** @var BehapiFactory */ |
||
20 | private $factory; |
||
21 | |||
22 | /** @var PropertyAccessor */ |
||
23 | private $accessor; |
||
24 | |||
25 | public function __construct(HttpHistory $history) |
||
30 | |||
31 | /** @Then the root should match: */ |
||
32 | public function root_should_match(PyStringNode $pattern) |
||
47 | |||
48 | /** @Then in the json, :path should match: */ |
||
49 | View Code Duplication | public function path_should_match(string $path, PyStringNode $pattern) |
|
68 | |||
69 | /** @Then in the json, :path should not match: */ |
||
70 | View Code Duplication | public function path_should_not_match(string $path, PyStringNode $pattern) |
|
89 | |||
90 | private function getJson(): string |
||
94 | |||
95 | private function getValue(string $path) |
||
99 | } |
||
100 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.