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 // phpcs:ignore WordPress.Files.FileName |
||
| 15 | class WP_Test_Autoloader extends TestCase { |
||
| 16 | /** |
||
| 17 | * Jetpack package classes. |
||
| 18 | * |
||
| 19 | * @var $jetpack_packages_classes |
||
| 20 | */ |
||
| 21 | public static $jetpack_packages_classes; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Test setup. |
||
| 25 | */ |
||
| 26 | public function setup() { |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Test tear down. |
||
| 35 | */ |
||
| 36 | public function tearDown() { |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Ensure enqueuing adds to the global array. |
||
| 45 | */ |
||
| 46 | View Code Duplication | public function test_enqueueing_adds_to_the_global_array() { |
|
| 54 | |||
| 55 | /** |
||
| 56 | * Tests that the latest version is added to the global array. |
||
| 57 | */ |
||
| 58 | View Code Duplication | public function test_enqueueing_adds_the_latest_version_to_the_global_array() { |
|
| 68 | |||
| 69 | /** |
||
| 70 | * Tests that the dev version is added to the global array. |
||
| 71 | */ |
||
| 72 | View Code Duplication | public function test_enqueueing_always_adds_the_dev_version_to_the_global_array() { |
|
| 83 | |||
| 84 | /** |
||
| 85 | * Ensures that an autoloaded class is available. |
||
| 86 | */ |
||
| 87 | public function test_enqueue_class_to_autoload_works_as_expected() { |
||
| 94 | } |
||
| 95 |