xtubeShowBannerB accesses the super-global variable $GLOBALS. Open
function xtubeShowBannerB($options)
{
$moduleDirName = \basename(\dirname(__DIR__));
$block = [];
- 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
xtubeShowBannerB accesses the super-global variable $GLOBALS. Open
function xtubeShowBannerB($options)
{
$moduleDirName = \basename(\dirname(__DIR__));
$block = [];
- 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
xtubeShowBannerB accesses the super-global variable $GLOBALS. Open
function xtubeShowBannerB($options)
{
$moduleDirName = \basename(\dirname(__DIR__));
$block = [];
- 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
xtubeShowBannerB accesses the super-global variable $GLOBALS. Open
function xtubeShowBannerB($options)
{
$moduleDirName = \basename(\dirname(__DIR__));
$block = [];
- 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
xtubeShowBannerB accesses the super-global variable $GLOBALS. Open
function xtubeShowBannerB($options)
{
$moduleDirName = \basename(\dirname(__DIR__));
$block = [];
- 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
xtubeShowBannerB accesses the super-global variable $GLOBALS. Open
function xtubeShowBannerB($options)
{
$moduleDirName = \basename(\dirname(__DIR__));
$block = [];
- 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
xtubeShowBannerB accesses the super-global variable $GLOBALS. Open
function xtubeShowBannerB($options)
{
$moduleDirName = \basename(\dirname(__DIR__));
$block = [];
- 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 xtubeShowBannerB
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function xtubeShowBannerB($options)
{
$moduleDirName = \basename(\dirname(__DIR__));
$block = [];
Function xtubeShowBannerB
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function xtubeShowBannerB($options)
{
$moduleDirName = \basename(\dirname(__DIR__));
$block = [];
- 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
Avoid using undefined variables such as '$_block_check_array' which will lead to PHP notices. Open
unset($_block_check_array);
- 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 xtubeShowBannerB uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$percent = mb_substr(100 * $clicks / $impmade, 0, 5);
}
- 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 xtubeShowBannerB uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$left = (int)$imptotal - (int)$impmade;
}
- 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 local variables such as '$_block_check_array'. Open
unset($_block_check_array);
- 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
Avoid unused parameters such as '$options'. Open
function xtubeShowBannerB($options)
- 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 '$xoopstubeModuleConfig'. Open
$xoopstubeModuleConfig = $configHandler->getConfigsByCat(0, $xoopstubeModule->getVar('mid'));
- 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
Avoid unused parameters such as '$options'. Open
function xtubeEditBannerB($options)
- 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 '$time'. Open
$time = time();
- 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
Avoid excessively long variable names like $xoopstubeModuleConfig. Keep variable name length under 20. Open
$xoopstubeModuleConfig = $configHandler->getConfigsByCat(0, $xoopstubeModule->getVar('mid'));
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Line exceeds 120 characters; contains 153 characters Open
$result2 = $GLOBALS['xoopsDB']->query('SELECT name FROM ' . $GLOBALS['xoopsDB']->prefix('bannerclient') . ' WHERE cid=' . (int)$myrow['cid']);
- Exclude checks
The variable $_block_check_array is not named in camelCase. Open
function xtubeShowBannerB($options)
{
$moduleDirName = \basename(\dirname(__DIR__));
$block = [];
- 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();
}
}