XoopsInfo_GetLastVersion accesses the super-global variable $GLOBALS. Open
function XoopsInfo_GetLastVersion()
{
global $modversion;
$version = @file_get_contents($modversion['status_fileinfo']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
XoopsInfo_UpdatedModule accesses the super-global variable $GLOBALS. Open
function XoopsInfo_UpdatedModule()
{
global $modversion;
if ($modversion['version'] != $GLOBALS['xoopsModule']->getVar('version') / 100) {
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
XoopsInfo_UpdatedModule accesses the super-global variable $GLOBALS. Open
function XoopsInfo_UpdatedModule()
{
global $modversion;
if ($modversion['version'] != $GLOBALS['xoopsModule']->getVar('version') / 100) {
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Method adminmenu
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function adminmenu($currentoption = 0, $breadcrumb = '')
{
global $xoopsModule, $xoopsConfig, $modversion;
/* Nice buttons styles */
Function adminmenu
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function adminmenu($currentoption = 0, $breadcrumb = '')
{
global $xoopsModule, $xoopsConfig, $modversion;
/* Nice buttons styles */
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function XoopsInfo_moduleoption
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
{
global $xoopsModuleConfig, $xoopsModule;
static $tbloptions = [];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function XoopsInfo_GetLastVersion
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function XoopsInfo_GetLastVersion()
{
global $modversion;
$version = @file_get_contents($modversion['status_fileinfo']);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function filemtime_override
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function filemtime_override($dirname, $template, $theme = '', $block = false)
{
global $xoopsConfig;
$themeset = '' == $theme ? $xoopsConfig['theme_set'] : $theme;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Consider simplifying this complex logical expression. Open
if (defined('_PHPSYSINFO') && defined('_PHPSECINFO')) {
$break = 4;
} elseif ((defined('_PHPSYSINFO') && !defined('_PHPSECINFO')) || (!defined('_PHPSYSINFO') && defined('_PHPSECINFO'))) {
$break = 3;
} elseif (!defined('_PHPSYSINFO') && !defined('_PHPSECINFO')) {
Function check_override
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function check_override($dirname, $template, $theme = '', $block = false)
{
global $xoopsConfig;
$themeset = '' == $theme ? $xoopsConfig['theme_set'] : $theme;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The function adminmenu() has an NPath complexity of 324. The configured NPath complexity threshold is 200. Open
function adminmenu($currentoption = 0, $breadcrumb = '')
{
global $xoopsModule, $xoopsConfig, $modversion;
/* Nice buttons styles */
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The function adminmenu() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10. Open
function adminmenu($currentoption = 0, $breadcrumb = '')
{
global $xoopsModule, $xoopsConfig, $modversion;
/* Nice buttons styles */
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The function XoopsInfo_moduleoption() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
{
global $xoopsModuleConfig, $xoopsModule;
static $tbloptions = [];
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Avoid using undefined variables such as '$adminmenu' which will lead to PHP notices. Open
$tblColors = array_fill(0, count($adminmenu), '');
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$adminmenu' which will lead to PHP notices. Open
for ($i = 0, $iMax = count($adminmenu); $i < $iMax; $i++) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$adminmenu' which will lead to PHP notices. Open
echo '<li id="' . $tblColors[$i] . '"><a href="' . XOOPSINFO_URL . $adminmenu[$i]['link'] . '"><span>' . $adminmenu[$i]['title'] . '</span></a></li>';
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$headermenu' which will lead to PHP notices. Open
for ($i = 0, $iMax = count($headermenu); $i < $iMax; $i++) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$headermenu' which will lead to PHP notices. Open
if ($i < count($headermenu) - 1) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$headermenu' which will lead to PHP notices. Open
echo '<a class="nobutton" href="' . $headermenu[$i]['link'] . '">' . $headermenu[$i]['title'] . '</a> ';
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$headermenu' which will lead to PHP notices. Open
echo '<a class="nobutton" href="' . $headermenu[$i]['link'] . '">' . $headermenu[$i]['title'] . '</a> ';
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$adminmenu' which will lead to PHP notices. Open
echo '<li id="' . $tblColors[$i] . '"><a href="' . XOOPSINFO_URL . $adminmenu[$i]['link'] . '"><span>' . $adminmenu[$i]['title'] . '</span></a></li>';
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Missing class import via use statement (line '157', column '24'). Open
$criteria->add(new Criteria('mid', 1), 'OR');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '165', column '27'). Open
$modules_select = new XoopsFormSelect(_AM_XI_MIME_MODULES, 'mid', $mid);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Remove error control operator '@' on line 293. Open
function XoopsInfo_GetLastVersion()
{
global $modversion;
$version = @file_get_contents($modversion['status_fileinfo']);
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Remove error control operator '@' on line 285. Open
function filemtime_override($dirname, $template, $theme = '', $block = false)
{
global $xoopsConfig;
$themeset = '' == $theme ? $xoopsConfig['theme_set'] : $theme;
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
The method check_override has a boolean flag argument $block, which is a certain sign of a Single Responsibility Principle violation. Open
function check_override($dirname, $template, $theme = '', $block = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '153', column '39'). Open
$criteria = new CriteriaCompo(new Criteria('hasmain', 1));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '153', column '21'). Open
$criteria = new CriteriaCompo(new Criteria('hasmain', 1));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method filemtime_override has a boolean flag argument $block, which is a certain sign of a Single Responsibility Principle violation. Open
function filemtime_override($dirname, $template, $theme = '', $block = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '155', column '24'). Open
$criteria->add(new Criteria('isactive', 1));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method adminmenu uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
include_once XOOPS_ROOT_PATH . '/modules/xoopsinfo/language/english/modinfo.php';
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method filemtime_override uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$filename = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/' . $template;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method XoopsInfo_GetLastVersion uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
echo $modversion['developer_website_url'] . '" target="_blank"><br><br><font color="#0000CC">' . $modversion['developer_website_name'];
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method filemtime_override uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (file_exists(XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/' . $template)) {
$filename = XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/' . $template;
} else {
$filename = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/' . $template;
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method check_override uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (file_exists(XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/' . $template)) {
return true;
}
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method filemtime_override uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$filename = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/blocks/' . $template;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method XoopsInfo_moduleoption uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$module_handler = xoops_getHandler('module');
$module = $module_handler->getByDirname($repmodule);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method XoopsInfo_GetLastVersion uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
echo '<div class="bg1" style="margin:20px 100px; padding:5px; border:2px solid #FF0000; text-align:center; font-weight:bold;">';
echo _AM_XI_NO_UPGRADE;
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid unused parameters such as '$breadcrumb'. Open
function adminmenu($currentoption = 0, $breadcrumb = '')
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused local variables such as '$modversion'. Open
global $xoopsModule, $xoopsConfig, $modversion;
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($block) {
if (file_exists(XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/blocks/' . $template)) {
$filename = XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/blocks/' . $template;
} else {
$filename = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/blocks/' . $template;
- 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 103.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else {
if (file_exists(XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/' . $template)) {
$filename = XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/' . $template;
} else {
$filename = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/' . $template;
- 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 103.
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
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 25 and the first side effect is on line 18. Open
<?php
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
echo '<td style="width: 100%; font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;">';
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
echo $modversion['developer_website_url'] . '" target="_blank"><br><br><font color="#0000CC">' . $modversion['developer_website_name'];
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
echo '<div class="bg1" style="margin:20px 100px; padding:5px; border:2px solid #FF0000; text-align:center; font-weight:bold;">';
- Exclude checks
Line exceeds 120 characters; contains 186 characters Open
#buttonbar a { float:left; background:url('" . XOOPS_URL . "/modules/xoopsinfo/images/left_both.png') no-repeat left top; margin:0; padding:0 0 0 5px; text-decoration:none; }
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
echo '<h3 style="margin:0 0 10px 0; text-align:center;">' . $xoopsModule->name() . ' ' . _AM_XI_MODULEADMIN . '</h3>';
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
$modules_select->addOption('templates.php?fct=templates&mid=' . $key . '&status=' . $status . '&theme=' . $theme, $value);
- Exclude checks
Line exceeds 120 characters; contains 245 characters Open
#buttonbar { float:left; width:100%; background: #e7e7e7 url('" . XOOPS_URL . "/modules/xoopsinfo/images/bg.png') repeat-x left bottom; font-size:93%; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; }
- Exclude checks
Line exceeds 120 characters; contains 267 characters Open
#buttonbar2 { float:left; width:100%; background: #e7e7e7 url('" . XOOPS_URL . "/modules/xoopsinfo/images/bg.png') repeat-x left bottom; font-size:93%; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; margin-bottom: 10px; }
- Exclude checks
Line exceeds 120 characters; contains 217 characters Open
#buttonbar2 a { float:left; background:url('" . XOOPS_URL . "/modules/xoopsinfo/images/left_both.png') no-repeat left top; margin:0; padding:0 0 0 5px; border-bottom:1px solid #000; text-decoration:none; }
- Exclude checks
Line exceeds 120 characters; contains 213 characters Open
#buttonbar a span { float:left; display:block; background:url('" . XOOPS_URL . "/modules/xoopsinfo/images/right_both.png') no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; }
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
} elseif ((defined('_PHPSYSINFO') && !defined('_PHPSECINFO')) || (!defined('_PHPSYSINFO') && defined('_PHPSECINFO'))) {
- Exclude checks
Line exceeds 120 characters; contains 214 characters Open
#buttonbar2 a span { float:left; display:block; background:url('" . XOOPS_URL . "/modules/xoopsinfo/images/right_both.png') no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; }
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
echo '<div class="bg1" style="margin:20px 100px; padding:5px; border:2px solid #FF0000; text-align:center; font-weight:bold;">';
- Exclude checks
Line exceeds 120 characters; contains 146 characters Open
echo $modversion['download_website'] . '" target="_blank"><br><br><font color="#0000CC">' . $modversion['developer_website_name'];
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
$redirect = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=' . $GLOBALS['xoopsModule']->getVar('dirname');
- Exclude checks
Line exceeds 120 characters; contains 207 characters Open
#buttontop { float:left; width:100%; background: #e7e7e7; font-size:93%; line-height:normal; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; margin: 0; }
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
#buttonbar ul { margin:0; margin-top: 15px; padding:10px 0 0; list-style:none; white-space: nowrap; float:left; }
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
echo '<li id="' . $tblColors[$i] . '"><a href="' . XOOPSINFO_URL . $adminmenu[$i]['link'] . '"><span>' . $adminmenu[$i]['title'] . '</span></a></li>';
- Exclude checks
Line exceeds 120 characters; contains 192 characters Open
echo '<div align="right"><br><a target="_blank" href="http://www.dugris.info/"><img src="' . XOOPS_URL . '/modules/xoopsinfo/images/xoopsinfo.gif" border="0" align="absmiddle"></a></div>';
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule && $xoopsModule->getVar('isactive'))) {
- Exclude checks
The variable $config_handler is not named in camelCase. Open
function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
{
global $xoopsModuleConfig, $xoopsModule;
static $tbloptions = [];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $module_list is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $module_list is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $modules_select is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $modules_select is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $modules_select is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $module_handler is not named in camelCase. Open
function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
{
global $xoopsModuleConfig, $xoopsModule;
static $tbloptions = [];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $module_handler is not named in camelCase. Open
function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
{
global $xoopsModuleConfig, $xoopsModule;
static $tbloptions = [];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $module_handler is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $module_list is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $modules_select is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $module_handler is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $module_list is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $modules_select is not named in camelCase. Open
function Template_GetModulesList()
{
global $mid, $theme, $status;
$module_handler = xoops_getHandler('module');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $config_handler is not named in camelCase. Open
function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
{
global $xoopsModuleConfig, $xoopsModule;
static $tbloptions = [];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}