mambax7/publisher

View on GitHub

Showing 3,032 of 3,032 total issues

The method uploadFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            return true;
        }
Severity: Minor
Found in class/Utility.php by phpmd

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 closeTags uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $completeTags = $startTags;
            }
Severity: Minor
Found in class/Utility.php by phpmd

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 closeTags uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                    } else {
                        $completeTags[] = $val;
                    }
Severity: Minor
Found in class/Utility.php by phpmd

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 ratingBar() has an NPath complexity of 960. The configured NPath complexity threshold is 200.
Open

    public static function ratingBar($itemId)
    {
        $helper          = Helper::getInstance();
        $ratingUnitWidth = 30;
        $units           = 5;
Severity: Minor
Found in class/Utility.php by phpmd

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

Avoid using static access to class '\XoopsUser' in method 'getValuesVote'.
Open

        $ret['uid']      = \XoopsUser::getUnameFromId($this->getVar('rate_uid'));
Severity: Minor
Found in class/Vote.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

The method getItemRating() has 164 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function getItemRating($itemId = null, $source = null): array
    {
        $itemId    = $itemId ?? 0;
        $source    = $source ?? 0;
        $xoopsUser = $GLOBALS['xoopsUser'];
Severity: Minor
Found in class/VoteHandler.php by phpmd

The method getItemRating() has an NPath complexity of 242. The configured NPath complexity threshold is 200.
Open

    public function getItemRating($itemId = null, $source = null): array
    {
        $itemId    = $itemId ?? 0;
        $source    = $source ?? 0;
        $xoopsUser = $GLOBALS['xoopsUser'];
Severity: Minor
Found in class/VoteHandler.php by phpmd

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 method getItemRating uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $text      = \str_replace('%c', $itemRating['avg_rate_value'], \_MA_PUBLISHER_RATING_CURRENT_X);
                $shorttext = \str_replace('%c', $itemRating['avg_rate_value'], \_MA_PUBLISHER_RATING_CURRENT_SHORT_X);
            }
Severity: Minor
Found in class/VoteHandler.php by phpmd

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 getItemRating5 uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $itemRating['uid']     = $uid;
            $itemRating['nb_vote'] = $count;
            $itemRating['voted']   = $voted;
            $itemRating['ip']      = $ip;
Severity: Minor
Found in class/VoteHandler.php by phpmd

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

xoops_module_install_publisher accesses the super-global variable $GLOBALS.
Open

function xoops_module_install_publisher(\XoopsModule $module)
{
    require \dirname(__DIR__) . '/preloads/autoloader.php';

    $helper       = Helper::getInstance();
Severity: Minor
Found in include/oninstall.php by phpmd

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

xoops_module_update_publisher accesses the super-global variable $GLOBALS.
Open

function xoops_module_update_publisher(\XoopsModule $module, ?string $previousVersion = null)
{
    //    global $GLOBALS['xoopsDB'];
    $moduleDirName = \basename(\dirname(__DIR__));
    //    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
Severity: Minor
Found in include/onupdate.php by phpmd

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

The method getURL() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
Open

    protected function getURL($url, $tempfile)
    {
        $this->lastURLError = false;
        $url                = preg_replace('/ /', '%20', $url);
        if (function_exists('curl_init')) {
Severity: Minor
Found in thumb.php by phpmd

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 publisher_items_recent_show() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
Open

function publisher_items_recent_show($options)
{
    $helper = Helper::getInstance();
    /** @var ItemHandler $itemHandler */
    $itemHandler = $helper->getHandler('Item');
Severity: Minor
Found in blocks/items_recent.php by phpmd

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

publisher_notify_iteminfo accesses the super-global variable $GLOBALS.
Open

function publisher_notify_iteminfo($category, $itemId)
{
    if ('global' === $category) {
        $item['name'] = '';
        $item['url']  = '';
Severity: Minor
Found in include/notification.inc.php by phpmd

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

xoops_module_update_publisher accesses the super-global variable $GLOBALS.
Open

function xoops_module_update_publisher(\XoopsModule $module, ?string $previousVersion = null)
{
    //    global $GLOBALS['xoopsDB'];
    $moduleDirName = \basename(\dirname(__DIR__));
    //    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
Severity: Minor
Found in include/onupdate.php by phpmd

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

The function xoops_module_install_publisher() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

function xoops_module_install_publisher(\XoopsModule $module)
{
    require \dirname(__DIR__) . '/preloads/autoloader.php';

    $helper       = Helper::getInstance();
Severity: Minor
Found in include/oninstall.php by phpmd

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

getLocalImagePath accesses the super-global variable $_SERVER.
Open

    protected function getLocalImagePath($src)
    {
        $src = ltrim($src, '/'); //strip off the leading '/'
        if (!$this->docRoot) {
            $this->debug(3, 'We have no document root set, so as a last resort, lets check if the image is in the current dir and serve that.');
Severity: Minor
Found in thumb.php by phpmd

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

xoops_module_update_publisher accesses the super-global variable $GLOBALS.
Open

function xoops_module_update_publisher(\XoopsModule $module, ?string $previousVersion = null)
{
    //    global $GLOBALS['xoopsDB'];
    $moduleDirName = \basename(\dirname(__DIR__));
    //    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
Severity: Minor
Found in include/onupdate.php by phpmd

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

xoops_module_update_publisher accesses the super-global variable $GLOBALS.
Open

function xoops_module_update_publisher(\XoopsModule $module, ?string $previousVersion = null)
{
    //    global $GLOBALS['xoopsDB'];
    $moduleDirName = \basename(\dirname(__DIR__));
    //    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
Severity: Minor
Found in include/onupdate.php by phpmd

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

xoops_module_update_publisher accesses the super-global variable $GLOBALS.
Open

function xoops_module_update_publisher(\XoopsModule $module, ?string $previousVersion = null)
{
    //    global $GLOBALS['xoopsDB'];
    $moduleDirName = \basename(\dirname(__DIR__));
    //    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
Severity: Minor
Found in include/onupdate.php by phpmd

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

Severity
Category
Status
Source
Language