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 |
||
| 23 | class Verification_PersonalMessage_Module extends ElkArte\sources\modules\Abstract_Module |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * {@inheritdoc } |
||
| 27 | */ |
||
| 28 | public static function hooks(\Event_Manager $eventsManager) |
||
| 29 | { |
||
| 30 | global $user_info, $modSettings; |
||
| 31 | |||
| 32 | // Are controls required? |
||
| 33 | if (!$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && $user_info['posts'] < $modSettings['pm_posts_verification']) |
||
| 34 | { |
||
| 35 | require_once(SUBSDIR . '/VerificationControls.class.php'); |
||
| 36 | |||
| 37 | // Add the events to call for the verification |
||
| 38 | return array( |
||
| 39 | array('prepare_send_context', array('Verification_PersonalMessage_Module', 'prepare_send_context'), array()), |
||
| 40 | array('before_sending', array('Verification_PersonalMessage_Module', 'before_sending'), array('post_errors')), |
||
| 41 | ); |
||
| 42 | } |
||
| 43 | else |
||
| 44 | return array(); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Prepare $context for the PM page. |
||
| 49 | */ |
||
| 50 | public function prepare_send_context() |
||
| 51 | { |
||
| 52 | global $context; |
||
| 53 | |||
| 54 | // Verification control needed for this PM? |
||
| 55 | $context['require_verification'] = true; |
||
| 56 | |||
| 57 | $verificationOptions = array( |
||
| 58 | 'id' => 'pm', |
||
| 59 | ); |
||
| 60 | $context['require_verification'] = create_control_verification($verificationOptions); |
||
| 61 | $context['visual_verification_id'] = $verificationOptions['id']; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Checks the user passed the verifications on the PM page. |
||
| 66 | * |
||
| 67 | * @param \ErrorContext $post_errors |
||
|
|
|||
| 68 | * @throws Elk_Exception |
||
| 69 | */ |
||
| 70 | public function before_sending($post_errors) |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } |
||
| 90 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths