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 | class ALNP_OceanWP { |
||
23 | |||
24 | /** |
||
25 | * Initlize Theme. |
||
26 | * |
||
27 | * @access public |
||
28 | * @static |
||
29 | */ |
||
30 | View Code Duplication | public static function init() { |
|
43 | |||
44 | /** |
||
45 | * Filters the location of the repeater template to override the default repeater template. |
||
46 | * |
||
47 | * @access public |
||
48 | * @return string |
||
49 | */ |
||
50 | public static function template_redirect() { |
||
53 | |||
54 | /** |
||
55 | * Filters the template location for get_template_part(). |
||
56 | * |
||
57 | * @access public |
||
58 | * @static |
||
59 | */ |
||
60 | public static function alnp_oceanwp_template_location() { |
||
63 | |||
64 | /** |
||
65 | * Add theme support by providing the theme selectors |
||
66 | * to be applied once the theme is activated. |
||
67 | * |
||
68 | * @access public |
||
69 | * @static |
||
70 | */ |
||
71 | public static function add_theme_support() { |
||
81 | |||
82 | } // END class |
||
83 | |||
85 |
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.