mambax7/publisher

View on GitHub

Showing 3,032 of 3,032 total issues

Avoid using static access to class '\Xmf\Request' in method 'uploadFile'.
Open

        $itemId  = Request::getInt('itemid', 0, 'POST');
Severity: Minor
Found in class/Utility.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 getItemRating5 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

Avoid using static access to class '\Xmf\Request' in method 'uploadFile'.
Open

        $session->set('publisher_file_filename', Request::getString('item_file_name', '', 'POST'));
Severity: Minor
Found in class/Utility.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

Avoid using static access to class 'XoopsModules\Publisher\Helper' in method 'ratingBar'.
Open

        $helper          = Helper::getInstance();
Severity: Minor
Found in class/Utility.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

Avoid using static access to class 'XoopsModules\Publisher\Helper' in method '__construct'.
Open

        $this->helper = $helper ?? Helper::getInstance();
Severity: Minor
Found in class/VoteHandler.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

Avoid unused local variables such as '$key'.
Open

                foreach ($startTags as $key => $val) {
Severity: Minor
Found in class/Utility.php by phpmd

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 using static access to class '\XoopsEditorHandler' in method 'getEditors'.
Open

        $editorHandler = \XoopsEditorHandler::getInstance();
Severity: Minor
Found in class/Utility.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 getEditors uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                //for admin permissions page
                $ret[$key]['name']  = $name;
                $ret[$key]['title'] = $title;
            }
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 getItemRating 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

Avoid using static access to class 'XoopsModules\Publisher\Session' in method 'uploadFile'.
Open

        $session = Session::getInstance();
Severity: Minor
Found in class/Utility.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

Avoid using static access to class '\Xmf\Request' in method 'uploadFile'.
Open

        $fileObj->setVar('description', Request::getString('item_file_description', '', 'POST'));
Severity: Minor
Found in class/Utility.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 uploadFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    return $message;
                }
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 getItemRating5() has 179 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

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

The method uploadFile() has an NPath complexity of 360. The configured NPath complexity threshold is 200.
Open

    public static function uploadFile($another, $withRedirect, &$itemObj = null)
    {
        \xoops_load('XoopsMediaUploader');
        //        require_once PUBLISHER_ROOT_PATH . '/class/uploader.php';

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 'XoopsModules\Publisher\Helper' in method 'uploadFile'.
Open

        $helper = Helper::getInstance();
Severity: Minor
Found in class/Utility.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

Avoid using static access to class '\Xmf\Request' in method 'uploadFile'.
Open

        $session->set('publisher_file_status', Request::getInt('item_file_status', 1, 'POST'));
Severity: Minor
Found in class/Utility.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

Avoid unused local variables such as '$ret'.
Open

            if (!$ret = $fileObj->checkUpload('item_upload_file', $allowedMimetypes, $errors)) {
Severity: Minor
Found in class/Utility.php by phpmd

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 using static access to class '\Xmf\Request' in method 'uploadFile'.
Open

        $fileObj->setVar('name', Request::getString('item_file_name', '', 'POST'));
Severity: Minor
Found in class/Utility.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

Avoid using static access to class '\Xmf\Request' in method 'uploadFile'.
Open

        $session->set('publisher_file_description', Request::getString('item_file_description', '', 'POST'));
Severity: Minor
Found in class/Utility.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

Avoid assigning values to variables in if clauses and the like (line '1435', column '24').
Open

    public static function convertCharset($item)
    {
        if (_CHARSET !== 'windows-1256') {
            return \utf8_encode($item);
        }
Severity: Minor
Found in class/Utility.php by phpmd

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Severity
Category
Status
Source
Language