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 PluginManagePage extends AbstractAdminPageStyleGuide |
||
17 | { |
||
18 | const 完了メーッセージ = '#page_admin_store_plugin > div.c-container > div.c-contentsArea > div.alert.alert-success.alert-dismissible.fade.show.m-3 > span'; |
||
19 | |||
20 | public function __construct(\AcceptanceTester $I) |
||
24 | |||
25 | public static function at($I) |
||
31 | |||
32 | /** |
||
33 | * @param $pluginCode |
||
34 | * |
||
35 | * @return PluginManagePage |
||
36 | */ |
||
37 | public function ストアプラグイン_有効化($pluginCode) |
||
41 | |||
42 | /** |
||
43 | * @param $pluginCode |
||
44 | * |
||
45 | * @return PluginManagePage |
||
46 | */ |
||
47 | public function ストアプラグイン_無効化($pluginCode) |
||
51 | |||
52 | /** |
||
53 | * @param $pluginCode |
||
54 | * |
||
55 | * @return PluginManagePage |
||
56 | * |
||
57 | * @throws \Exception |
||
58 | */ |
||
59 | public function ストアプラグイン_削除($pluginCode) |
||
69 | |||
70 | View Code Duplication | private function ストアプラグイン_ボタンクリック($pluginCode, $label) |
|
77 | |||
78 | public function 独自プラグイン_有効化($pluginCode) |
||
82 | |||
83 | public function 独自プラグイン_無効化($pluginCode) |
||
87 | |||
88 | public function 独自プラグイン_削除($pluginCode) |
||
96 | |||
97 | View Code Duplication | private function 独自プラグイン_ボタンクリック($pluginCode, $label) |
|
104 | } |
||
105 |
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.