Avoid deeply nested control flow statements. Open
if (!$tpl_updated && $config->getVar('conf_catid') == XOOPS_CONF
&& $config->getVar('conf_name') === 'template_set'
) {
// clear cached/compiled files and regenerate them if default theme has been changed
if ($xoopsConfig['template_set'] != $_POST[$config->getVar('conf_name')]) {
Avoid deeply nested control flow statements. Open
if (!$startmod_updated && $new_value != '--' && $config->getVar('conf_catid') == XOOPS_CONF
&& $config->getVar('conf_name') === 'startpage'
) {
$memberHandler = xoops_getHandler('member');
$groups = $memberHandler->getGroupList();
Avoid deeply nested control flow statements. Open
if (!$theme_updated && $config->getVar('conf_catid') == XOOPS_CONF
&& $config->getVar('conf_name') === 'theme_set'
) {
$memberHandler = xoops_getHandler('member');
$memberHandler->updateUsersByField('theme', $_POST[$config->getVar('conf_name')]);
Avoid deeply nested control flow statements. Open
if (!$lang_updated && $config->getVar('conf_catid') == XOOPS_CONF
&& $config->getVar('conf_name') === 'language'
) {
// regenerate admin menu file
$xoopsConfig['language'] = $_POST[$config->getVar('conf_name')];
Identical blocks of code found in 2 locations. Consider refactoring. Open
for ($j = 0; $j < $opcount; ++$j) {
$optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
$optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
$ele->addOption($optval, $optkey);
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 144.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
for ($j = 0; $j < $opcount; ++$j) {
$optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
$optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
$ele->addOption($optval, $optkey);
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 144.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Only one argument is allowed per line in a multi-line function call Open
$ele = ($config[$i]->getVar('conf_value') !== '') ? new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'),
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$myts->htmlspecialchars(implode('|', $config[$i]->getConfValueForOutput())), 5,
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
- Exclude checks
Line exceeds 120 characters; contains 156 characters Open
// $form->addElement(new XoopsFormHidden('redirect', XOOPS_URL.'/modules/'.$module->getVar('dirname').'/'.$module->getInfo('adminindex')));
- Exclude checks
Line exceeds 120 characters; contains 177 characters Open
$myts->htmlspecialchars(implode('|', $config[$i]->getConfValueForOutput())), 5,
- Exclude checks
Line exceeds 120 characters; contains 165 characters Open
$ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()), 5, 50);
- Exclude checks
Line exceeds 120 characters; contains 165 characters Open
$optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
- Exclude checks
Line exceeds 120 characters; contains 164 characters Open
$ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
- Exclude checks
Line exceeds 120 characters; contains 175 characters Open
. '<br><br><span style="font-weight:normal;">'
- Exclude checks
Line exceeds 120 characters; contains 168 characters Open
$optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$options = $configHandler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
$ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
- Exclude checks
Line exceeds 120 characters; contains 173 characters Open
. constant($config[$i]->getVar('conf_desc'))
- Exclude checks
Line exceeds 120 characters; contains 147 characters Open
$ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
. '/admin/admin.php?fct=preferences&op=showmod&mod='
- Exclude checks
Line exceeds 120 characters; contains 172 characters Open
|| constant($config[$i]->getVar('conf_desc')) === '') ? constant($config[$i]->getVar('conf_title')) : constant($config[$i]->getVar('conf_title'))
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
$ele = new XoopsFormColorPicker($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
$ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
- Exclude checks
Line exceeds 120 characters; contains 168 characters Open
$optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
$ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO);
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
$ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
$found = $tplfileHandler->find($newtplset, 'block', $dtemplates[$j]->getVar('tpl_refid'), null);
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
require_once XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php';
- Exclude checks
Line exceeds 120 characters; contains 179 characters Open
50) : new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), '', 5, 50);
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
if (!$fp = fopen(XOOPS_CACHE_PATH . '/' . $newtplset . '_' . $imagefiles[$j]->getVar('imgsetimg_file'), 'wb')) {
- Exclude checks
Line exceeds 120 characters; contains 165 characters Open
$optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
$ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$options = $configHandler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
$ele = ($config[$i]->getVar('conf_value') !== '') ? new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'),
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true);
- Exclude checks
Multi-line function call not indented correctly; expected 24 spaces but found 98 Open
50) : new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), '', 5, 50);
- Exclude checks
Multi-line function call not indented correctly; expected 28 spaces but found 98 Open
$myts->htmlspecialchars(implode('|', $config[$i]->getConfValueForOutput())), 5,
- Exclude checks
Opening parenthesis of a multi-line function call must be the last content on the line Open
$ele = ($config[$i]->getVar('conf_value') !== '') ? new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'),
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
50) : new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), '', 5, 50);
- Exclude checks