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 |
||
14 | class AdminContext extends DefaultContext |
||
15 | { |
||
16 | /** |
||
17 | * @Then /^I should be on the page of ([^""(w)]*) "([^""]*)"$/ |
||
18 | * @Then /^I should still be on the page of ([^""(w)]*) "([^""]*)"$/ |
||
19 | */ |
||
20 | public function iShouldBeOnTheResourcePageByName($type, $name) |
||
24 | |||
25 | /** |
||
26 | * @When /^I (?:click|press|follow) "([^"]*)" near "([^"]*)"$/ |
||
27 | */ |
||
28 | View Code Duplication | public function iClickNear($button, $value) |
|
41 | |||
42 | /** |
||
43 | * @Then /^I should see "([^"]*)" near "([^"]*)"$/ |
||
44 | */ |
||
45 | public function iShouldSeeNear($text, $value) |
||
51 | |||
52 | /** |
||
53 | * @Then /^I should see the dedipanel version "(?<version>[^"]+)"$/ |
||
54 | */ |
||
55 | public function iShouldSeeTheDedipanelVersion($version) |
||
59 | |||
60 | /** |
||
61 | * @Then /^I should see "(?<value>[^"]+)" selected in "(?<select>[^"]+)"$/ |
||
62 | */ |
||
63 | public function iShouldSeeSelectedIn($select, $value) |
||
69 | } |
||
70 |
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.