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 |
||
16 | class VictoireContext extends RawMinkContext |
||
17 | { |
||
18 | use KernelDictionary; |
||
19 | protected $minkContext; |
||
20 | |||
21 | /** @BeforeScenario */ |
||
22 | public function gatherContexts(BeforeScenarioScope $scope) |
||
27 | |||
28 | /** |
||
29 | * @BeforeScenario |
||
30 | * |
||
31 | * @param BeforeScenarioScope $scope |
||
32 | */ |
||
33 | public function resetViewsReference(BeforeScenarioScope $scope) |
||
38 | |||
39 | /** |
||
40 | * @Given I am logged in as :email |
||
41 | */ |
||
42 | public function iAmLoggedInAsUser($email) |
||
49 | |||
50 | /** |
||
51 | * @Given I login as visitor |
||
52 | */ |
||
53 | public function iLoginAsVisitor() |
||
59 | |||
60 | /** |
||
61 | * @Given /^I visit homepage through domain "([^"]*)"$/ |
||
62 | */ |
||
63 | public function ivisitHomepageThroughDomain($domain) |
||
70 | |||
71 | /** |
||
72 | * @Then /^I fill in wysiwyg with "([^"]*)"$/ |
||
73 | */ |
||
74 | public function iFillInWysiwygOnFieldWith($arg) |
||
79 | |||
80 | /** |
||
81 | * @Then /^I select "([^"]*)" from the "([^"]*)" select of "([^"]*)" slot$/ |
||
82 | */ |
||
83 | public function iSelectFromTheSelectOfSlot($widget, $nth, $slot) |
||
89 | |||
90 | /** |
||
91 | * @Then /^I switch to "([^"]*)" mode$/ |
||
92 | */ |
||
93 | View Code Duplication | public function iSwitchToMode($mode) |
|
103 | |||
104 | /** |
||
105 | * @Then /^I (open|close|toggle) the hamburger menu$/ |
||
106 | */ |
||
107 | View Code Duplication | public function iOpenTheHamburgerMenu() |
|
117 | |||
118 | /** |
||
119 | * @When I follow the tab :name |
||
120 | */ |
||
121 | View Code Duplication | public function iFollowTheTab($name) |
|
131 | |||
132 | /** |
||
133 | * @Then /^I submit the widget$/ |
||
134 | * @Then /^I submit the modal$/ |
||
135 | */ |
||
136 | public function iSubmitTheWidget() |
||
146 | |||
147 | /** |
||
148 | * @Given /^I edit an "([^"]*)" widget$/ |
||
149 | * @Given /^I edit the "([^"]*)" widget$/ |
||
150 | */ |
||
151 | public function iEditTheWidget($widgetType) |
||
166 | |||
167 | /** |
||
168 | * @Then /^"([^"]*)" should precede "([^"]*)"$/ |
||
169 | */ |
||
170 | public function shouldPrecedeForTheQuery($textBefore, $textAfter) |
||
184 | |||
185 | /** |
||
186 | * @When /^I select the option "(?P<option>[^"]*)" in the dropdown "(?P<dropdown>[^"]*)"$/ |
||
187 | */ |
||
188 | public function iSelectTheOptionInTheDropdown($option, $dropdown) |
||
195 | |||
196 | /** |
||
197 | * @Then /^I attach image with id "(\d+)" to victoire field "(.+)"$/ |
||
198 | */ |
||
199 | public function attachImageToVictoireScript($imageId, $fieldId) |
||
204 | |||
205 | /** |
||
206 | * @Then I should find css element :element with selector :selector and value :value |
||
207 | */ |
||
208 | public function iShouldFindCssWithSelectorAndValue($element, $selector, $value) |
||
219 | |||
220 | /** |
||
221 | * Try to find value in element and retry for a given time. |
||
222 | * |
||
223 | * @param Element $element |
||
224 | * @param string $selectorType xpath|css |
||
225 | * @param string $value |
||
226 | * @param int $timeout |
||
227 | */ |
||
228 | protected function findOrRetry(Element $element, $selectorType, $value, $timeout = 10000) |
||
244 | |||
245 | /** |
||
246 | * @Then I should see disable tab :name |
||
247 | */ |
||
248 | View Code Duplication | public function iShouldSeeDisableTab($name) |
|
257 | |||
258 | /** |
||
259 | * @Then /^I move the widgetMap "(.+)" "(.+)" the widgetMap "(.*)"$/ |
||
260 | */ |
||
261 | public function iMoveWidgetUnder($widgetMapMoved, $position, $widgetMapMovedTo) |
||
270 | } |
||
271 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.