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 |
||
22 | View Code Duplication | class ALNP_Twenty_Nineteen { |
|
1 ignored issue
–
show
|
|||
23 | |||
24 | /** |
||
25 | * Initlize Theme. |
||
26 | * |
||
27 | * @access public |
||
28 | * @static |
||
29 | */ |
||
30 | public static function init() { |
||
37 | |||
38 | /** |
||
39 | * Add theme support by providing the theme selectors |
||
40 | * to be applied once the theme is activated. |
||
41 | * |
||
42 | * @access public |
||
43 | * @static |
||
44 | */ |
||
45 | public static function add_theme_support() { |
||
55 | |||
56 | /** |
||
57 | * Filters the location of the repeater template. |
||
58 | * |
||
59 | * @access public |
||
60 | * @static |
||
61 | * @return string |
||
62 | */ |
||
63 | public static function alnp_make_template_redirect() { |
||
66 | |||
67 | } // END class |
||
68 | |||
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.