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 namespace Xoopsmodules\instruction; |
||
13 | class PageHandler extends \XoopsPersistableObjectHandler |
||
14 | { |
||
15 | /** |
||
16 | * @param null|mixed $db |
||
17 | */ |
||
18 | public function __construct(\XoopsDatabase $db = null) |
||
22 | |||
23 | /** |
||
24 | * Generate function for update user post |
||
25 | * |
||
26 | * @ Update user post count after send approve content |
||
27 | * @ Update user post count after change status content |
||
28 | * @ Update user post count after delete content |
||
29 | * @param $uid |
||
30 | * @param $status |
||
31 | * @param $action |
||
32 | */ |
||
33 | public function updateposts($uid, $status, $action) |
||
71 | } |
||
72 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.