| Conditions | 8 | 
| Paths | 72 | 
| Total Lines | 150 | 
| Code Lines | 71 | 
| Lines | 21 | 
| Ratio | 14 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 82 | function editcat($showmenu = false, $categoryid = 0)  | 
            ||
| 83 | { | 
            ||
| 84 | //$moderators = array(); // just to define the variable  | 
            ||
| 85 | //$allmods = array();  | 
            ||
| 86 | $startfaq = isset($_GET['startfaq']) ? (int)$_GET['startfaq'] : 0;  | 
            ||
| 87 | global $categoryHandler, $xoopsUser, $xoopsUser, $myts, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $_GET;  | 
            ||
| 88 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';  | 
            ||
| 89 | |||
| 90 | // Creating the faq handler object  | 
            ||
| 91 | /** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */  | 
            ||
| 92 |     $faqHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Faq'); | 
            ||
| 93 | |||
| 94 | echo '<script type="text/javascript" src="funcs.js"></script>';  | 
            ||
| 95 | echo '<style>';  | 
            ||
| 96 | echo '<!-- ';  | 
            ||
| 97 |     echo 'select { width: 130px; }'; | 
            ||
| 98 | echo '-->';  | 
            ||
| 99 | echo '</style>';  | 
            ||
| 100 | // If there is a parameter, and the id exists, retrieve data: we're editing a category  | 
            ||
| 101 |     if (0 != $categoryid) { | 
            ||
| 102 | |||
| 103 | // Creating the category object for the selected category  | 
            ||
| 104 | $categoryObj = new \XoopsModules\Smartfaq\Category($categoryid);  | 
            ||
| 105 | |||
| 106 | echo "<br>\n";  | 
            ||
| 107 |         if ($categoryObj->notLoaded()) { | 
            ||
| 108 |             redirect_header('category.php', 1, _AM_SF_NOCOLTOEDIT); | 
            ||
| 109 | }  | 
            ||
| 110 |         Smartfaq\Utility::collapsableBar('bottomtable', 'bottomtableicon'); | 
            ||
| 111 | echo "<img id='bottomtableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a> " . _AM_SF_EDITCOL . '</h3>';  | 
            ||
| 112 | echo "<div id='bottomtable'>";  | 
            ||
| 113 |     } else { | 
            ||
| 114 | $categoryObj = $categoryHandler->create();  | 
            ||
| 115 | echo "<br>\n";  | 
            ||
| 116 |         Smartfaq\Utility::collapsableBar('bottomtable', 'bottomtableicon'); | 
            ||
| 117 | echo "<img id='bottomtableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a> " . _AM_SF_CATEGORY_CREATE . '</h3>';  | 
            ||
| 118 | echo "<div id='bottomtable'>";  | 
            ||
| 119 | }  | 
            ||
| 120 | // Start category form  | 
            ||
| 121 |     $sform = new \XoopsThemeForm(_AM_SF_CATEGORY, 'op', xoops_getenv('PHP_SELF'), 'post', true); | 
            ||
| 122 |     $sform->setExtra('enctype="multipart/form-data"'); | 
            ||
| 123 | |||
| 124 | // Name  | 
            ||
| 125 |     $sform->addElement(new \XoopsFormText(_AM_SF_CATEGORY, 'name', 50, 255, $categoryObj->name('e')), true); | 
            ||
| 126 | |||
| 127 | // Parent Category  | 
            ||
| 128 |     $mytree = new Smartfaq\Tree($xoopsDB->prefix('smartfaq_categories'), 'categoryid', 'parentid'); | 
            ||
| 129 | ob_start();  | 
            ||
| 130 |     $mytree->makeMySelBox('name', 'weight', $categoryObj->parentid(), 1, 'parentid'); | 
            ||
| 131 | |||
| 132 | //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="")  | 
            ||
| 133 | $sform->addElement(new \XoopsFormLabel(_AM_SF_PARENT_CATEGORY_EXP, ob_get_contents()));  | 
            ||
| 134 | ob_end_clean();  | 
            ||
| 135 | |||
| 136 |     /*  $mytree = new Smartfaq\Tree($xoopsDB->prefix("smartfaq_categories"), "categoryid" , "parentid"); | 
            ||
| 137 | ob_start();  | 
            ||
| 138 |         $sform->addElement(new \XoopsFormHidden('categoryid', $categoryObj->categoryid())); | 
            ||
| 139 |         $mytree->makeMySelBox("name", "weight", $categoryObj->categoryid()); | 
            ||
| 140 | $sform->addElement(new \XoopsFormLabel(_AM_SF_CATEGORY_FAQ, ob_get_contents()));  | 
            ||
| 141 | ob_end_clean();  | 
            ||
| 142 | */  | 
            ||
| 143 | |||
| 144 | // Decsription  | 
            ||
| 145 |     $sform->addElement(new \XoopsFormTextArea(_AM_SF_COLDESCRIPT, 'description', $categoryObj->description('e'), 7, 60)); | 
            ||
| 146 | |||
| 147 | // Weight  | 
            ||
| 148 | $sform->addElement(new \XoopsFormText(_AM_SF_COLPOSIT, 'weight', 4, 4, $categoryObj->weight()));  | 
            ||
| 149 | |||
| 150 | // READ PERMISSIONS  | 
            ||
| 151 |     $memberHandler = xoops_getHandler('member'); | 
            ||
| 152 | $group_list = $memberHandler->getGroupList();  | 
            ||
| 153 | |||
| 154 | $groups_read_checkbox = new \XoopsFormCheckBox(_AM_SF_PERMISSIONS_CAT_READ, 'groups_read[]', $categoryObj->getGroups_read());  | 
            ||
| 155 |     foreach ($group_list as $group_id => $group_name) { | 
            ||
| 156 |         if (XOOPS_GROUP_ADMIN != $group_id) { | 
            ||
| 157 | $groups_read_checkbox->addOption($group_id, $group_name);  | 
            ||
| 158 | }  | 
            ||
| 159 | }  | 
            ||
| 160 | $sform->addElement($groups_read_checkbox);  | 
            ||
| 161 | // Apply permissions on all faqs  | 
            ||
| 162 | $addapplyall_radio = new \XoopsFormRadioYN(_AM_SF_PERMISSIONS_APPLY_ON_FAQS, 'applyall', 0, ' ' . _AM_SF_YES . '', ' ' . _AM_SF_NO . '');  | 
            ||
| 163 | $sform->addElement($addapplyall_radio);  | 
            ||
| 164 | // MODERATORS  | 
            ||
| 165 | //$moderators_tray = new \XoopsFormElementTray(_AM_SF_MODERATORS_DEF, '');  | 
            ||
| 166 | |||
| 167 |     $module_id = $xoopsModule->getVar('mid'); | 
            ||
| 168 | |||
| 169 |     /*$gpermHandler = xoops_getHandler('groupperm'); | 
            ||
| 170 |     $mod_perms = $gpermHandler->getGroupIds('category_moderation', $categoryid, $module_id); | 
            ||
| 171 | |||
| 172 |     $moderators_select = new \XoopsFormSelect('', 'moderators', $moderators, 5, true); | 
            ||
| 173 | $moderators_tray->addElement($moderators_select);  | 
            ||
| 174 | |||
| 175 |     $butt_mngmods = new \XoopsFormButton('', '', 'Manage mods', 'button'); | 
            ||
| 176 |     $butt_mngmods->setExtra('onclick="javascript:small_window(\'pop.php\', 370, 350);"'); | 
            ||
| 177 | $moderators_tray->addElement($butt_mngmods);  | 
            ||
| 178 | |||
| 179 |     $butt_delmod = new \XoopsFormButton('', '', 'Delete mod', 'button'); | 
            ||
| 180 |     $butt_delmod->setExtra('onclick="javascript:deleteSelectedItemsFromList(this.form.elements[\'moderators[]\']);"'); | 
            ||
| 181 | $moderators_tray->addElement($butt_delmod);  | 
            ||
| 182 | |||
| 183 | $sform->addElement($moderators_tray);  | 
            ||
| 184 | */  | 
            ||
| 185 |     $sform->addElement(new \XoopsFormHidden('categoryid', $categoryid)); | 
            ||
| 186 | |||
| 187 | // Action buttons tray  | 
            ||
| 188 |     $button_tray = new \XoopsFormElementTray('', ''); | 
            ||
| 189 | |||
| 190 |     /*for ($i = 0, $iMax = count($moderators); $i < $iMax; ++$i) { | 
            ||
| 191 | $allmods[] = $moderators[$i];  | 
            ||
| 192 | }  | 
            ||
| 193 | |||
| 194 |     $hiddenmods = new \XoopsFormHidden('allmods', $allmods); | 
            ||
| 195 | $button_tray->addElement($hiddenmods);  | 
            ||
| 196 | */  | 
            ||
| 197 |     $hidden = new \XoopsFormHidden('op', 'addcategory'); | 
            ||
| 198 | $button_tray->addElement($hidden);  | 
            ||
| 199 | // No ID for category -- then it's new category, button says 'Create'  | 
            ||
| 200 |     if (!$categoryid) { | 
            ||
| 201 |         $butt_create = new \XoopsFormButton('', '', _AM_SF_CREATE, 'submit'); | 
            ||
| 202 |         $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); | 
            ||
| 203 | $button_tray->addElement($butt_create);  | 
            ||
| 204 | |||
| 205 |         $butt_clear = new \XoopsFormButton('', '', _AM_SF_CLEAR, 'reset'); | 
            ||
| 206 | $button_tray->addElement($butt_clear);  | 
            ||
| 207 | |||
| 208 |         $butt_cancel = new \XoopsFormButton('', '', _AM_SF_CANCEL, 'button'); | 
            ||
| 209 |         $butt_cancel->setExtra('onclick="history.go(-1)"'); | 
            ||
| 210 | $button_tray->addElement($butt_cancel);  | 
            ||
| 211 |     } else { | 
            ||
| 212 | // button says 'Update'  | 
            ||
| 213 |         $butt_create = new \XoopsFormButton('', '', _AM_SF_MODIFY, 'submit'); | 
            ||
| 214 |         $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); | 
            ||
| 215 | $button_tray->addElement($butt_create);  | 
            ||
| 216 | |||
| 217 |         $butt_cancel = new \XoopsFormButton('', '', _AM_SF_CANCEL, 'button'); | 
            ||
| 218 |         $butt_cancel->setExtra('onclick="history.go(-1)"'); | 
            ||
| 219 | $button_tray->addElement($butt_cancel);  | 
            ||
| 220 | }  | 
            ||
| 221 | |||
| 222 | $sform->addElement($button_tray);  | 
            ||
| 223 | $sform->display();  | 
            ||
| 224 | echo '</div>';  | 
            ||
| 225 | |||
| 226 |     if ($categoryid) { | 
            ||
| 227 | require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/displayfaqs.php';  | 
            ||
| 228 | }  | 
            ||
| 229 | |||
| 230 | unset($hidden);  | 
            ||
| 231 | }  | 
            ||
| 232 | |||
| 380 | 
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