Method render
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render($currentoption = 1, $display = true)
{
global $modversion;
$_dirname = $this->_obj->getVar('dirname');
$i = 0;
Function render
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function render($currentoption = 1, $display = true)
{
global $modversion;
$_dirname = $this->_obj->getVar('dirname');
$i = 0;
- 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 addMenuTopArray
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function addMenuTopArray($options, $multi = true)
{
if (is_array($options)) {
if ($multi === true) {
foreach ($options as $k => $v) {
- 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 addMenuTabsArray
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function addMenuTabsArray($options, $multi = true)
{
if (is_array($options)) {
if ($multi === true) {
foreach ($options as $k => $v) {
- 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 method render() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function render($currentoption = 1, $display = true)
{
global $modversion;
$_dirname = $this->_obj->getVar('dirname');
$i = 0;
- 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 '$menuItems' which will lead to PHP notices. Open
$menuItems[$currentoption] = 'current';
- 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 '$menuItems' which will lead to PHP notices. Open
$menuItems[] = $menus;
- 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 '$menuItems' which will lead to PHP notices. Open
$menu .= "<li id='" . $menuItems[$i] . "'><a href='" . XOOPS_URL . '/modules/' . $this->_obj->getVar('dirname') . '/' . $k . "'><span>$v</span></a></li>\n";
- 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 '$menuItems' which will lead to PHP notices. Open
$breadcrumb = $menuItems[$currentoption];
- 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
The method render has a boolean flag argument $display, which is a certain sign of a Single Responsibility Principle violation. Open
public function render($currentoption = 1, $display = true)
- 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
The method addMenuTopArray has a boolean flag argument $multi, which is a certain sign of a Single Responsibility Principle violation. Open
public function addMenuTopArray($options, $multi = true)
- 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
The method addMenuTabsArray has a boolean flag argument $multi, which is a certain sign of a Single Responsibility Principle violation. Open
public function addMenuTabsArray($options, $multi = true)
- 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
The method addMenuTabs uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->_menutabs[$value] = $value;
}
- 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 addMenuTabsArray uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
foreach ($options as $k) {
$this->addMenuTabsTop($k, $k);
}
}
- 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 render uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$menu .= ' ' . $this->_header . "</h4>\n";
}
- 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 addMenuTopArray uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
foreach ($options as $k) {
$this->addOptiontop($k, $k);
}
}
- 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 render uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$system_image = XOOPS_URL . '/modules/' . $_dirname . '/assets/images/' . $modversion['image'];
}
- 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 render uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return $menu;
}
- 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 addMenuTop uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->_menutop[$value] = $value;
}
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class APCalAdminMenuHandler
- Exclude checks
The property $_menutop is not named in camelCase. Open
class APCalAdminMenuHandler
{
/**
*
* @var string
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_header is not named in camelCase. Open
class APCalAdminMenuHandler
{
/**
*
* @var string
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_obj is not named in camelCase. Open
class APCalAdminMenuHandler
{
/**
*
* @var string
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_subheader is not named in camelCase. Open
class APCalAdminMenuHandler
{
/**
*
* @var string
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = 0;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The property $_menutabs is not named in camelCase. Open
class APCalAdminMenuHandler
{
/**
*
* @var string
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
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 23 and the first side effect is on line 18. Open
<?php
- Exclude checks
Property name "$_obj" should not be prefixed with an underscore to indicate visibility Open
public $_obj;
- Exclude checks
Property name "$_subheader" should not be prefixed with an underscore to indicate visibility Open
public $_subheader;
- Exclude checks
Method name "APCalAdminMenuHandler::breadcrumb_nav" is not in camel caps format Open
public function breadcrumb_nav($basename = 'Home')
- Exclude checks
Property name "$_menutop" should not be prefixed with an underscore to indicate visibility Open
public $_menutop = array();
- Exclude checks
Property name "$_menutabs" should not be prefixed with an underscore to indicate visibility Open
public $_menutabs = array();
- Exclude checks
Property name "$_header" should not be prefixed with an underscore to indicate visibility Open
public $_header;
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
$menu = '<style type="text/css" media="screen">@import "' . XOOPS_URL . '/modules/' . $this->_obj->getVar('dirname') . '/css/menu.css";</style>';
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
$menu .= "<td style='text-align: right;'><strong>" . $this->_obj->getVar('name') . '</strong> : ' . $breadcrumb . '</td>';
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
//Not the best method of adding CSS but the only method available at the moment since xoops is shitty with the backend
- Exclude checks
Line exceeds 120 characters; contains 168 characters Open
$menu .= "<li id='" . $menuItems[$i] . "'><a href='" . XOOPS_URL . '/modules/' . $this->_obj->getVar('dirname') . '/' . $k . "'><span>$v</span></a></li>\n";
- Exclude checks
The variable $return_str is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- 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 $bc_site is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- 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 $bc_site is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- 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 $bc_site is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- 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 $return_str is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- 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 $system_image is not named in camelCase. Open
public function render($currentoption = 1, $display = true)
{
global $modversion;
$_dirname = $this->_obj->getVar('dirname');
$i = 0;
- 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 $system_image is not named in camelCase. Open
public function render($currentoption = 1, $display = true)
{
global $modversion;
$_dirname = $this->_obj->getVar('dirname');
$i = 0;
- 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 $return_str is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- 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 $return_str is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- 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 $_dirname is not named in camelCase. Open
public function render($currentoption = 1, $display = true)
{
global $modversion;
$_dirname = $this->_obj->getVar('dirname');
$i = 0;
- 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 $bc_label is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- 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 $system_image is not named in camelCase. Open
public function render($currentoption = 1, $display = true)
{
global $modversion;
$_dirname = $this->_obj->getVar('dirname');
$i = 0;
- 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 $bc_label is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- 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 $bc_label is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- 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 $_dirname is not named in camelCase. Open
public function render($currentoption = 1, $display = true)
{
global $modversion;
$_dirname = $this->_obj->getVar('dirname');
$i = 0;
- 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 method breadcrumb_nav is not named in camelCase. Open
public function breadcrumb_nav($basename = 'Home')
{
global $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<a href=\"/\">$basename</a>";
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}