mambax7/publisher

View on GitHub

Showing 3,032 of 3,032 total issues

Avoid using static access to class '\XoopsDatabaseFactory' in method 'getHandler'.
Open

        $db     = \XoopsDatabaseFactory::getDatabaseConnection();
Severity: Minor
Found in class/Helper.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 '$breakWords'.
Open

                    $ret = Utility::truncateHtml($ret, $maxLength, $etc = '...', $breakWords = false);
Severity: Minor
Found in class/Item.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 '\XoopsDatabaseFactory' in method '__construct'.
Open

        $this->db = \XoopsDatabaseFactory::getDatabaseConnection();
Severity: Minor
Found in class/Item.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 '\MyTextSanitizer' in method 'wrapPage'.
Open

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

            } else {
                // compare selected in options with readable of user
                $catlist = \array_intersect($catlist, $imgcatConfig);
                $catids  = \array_keys($catlist);
            }
Severity: Minor
Found in class/Form/ItemForm.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\Utility' in method 'createElements'.
Open

        $allowedEditors = Utility::getEditors(
            $helper->getHandler('Permission')
                   ->getGrantedItems('editors')
        );
Severity: Minor
Found in class/Form/ItemForm.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 createElements uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $dateexpire_opt = 1;
                $dateexpire     = $obj->getVar('dateexpire');
            }
Severity: Minor
Found in class/Form/ItemForm.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 class Item has 1185 lines of code. Current threshold is 1000. Avoid really long classes.
Open

class Item extends \XoopsObject
{
    public const PAGEWRAP = '[pagewrap=';
    public const BODYTAG  = '<body>';
    /**
Severity: Minor
Found in class/Item.php by phpmd

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

        } else {
            $buttonTray->addElement(new \XoopsFormButton('', 'additem', _SUBMIT, 'submit')); //orclone
        }
Severity: Minor
Found in class/Form/ItemForm.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 checkRight uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $criteria->add(new \Criteria('gperm_groupid', $gpermGroupId));
        }
Severity: Minor
Found in class/GroupPermHandler.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 getBlockSummary uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $ret = $this->getSummary($maxLength, 's', '<br><br>');
        }
Severity: Minor
Found in class/Item.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 highlight uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $pattern   = '#(?!<.*?)(%s)(?![^<>]*?>)#';
            $slPattern = '#<a\s(?:.*?)>(%s)</a>#';
        }
Severity: Minor
Found in class/Highlighter.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\Utility' in method 'getTitle'.
Open

                    $ret = Utility::substr($ret, 0, $maxLength);
Severity: Minor
Found in class/Item.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\Utility' in method 'getSubtitle'.
Open

                    $ret = Utility::substr($ret, 0, $maxLength);
Severity: Minor
Found in class/Item.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 createElements uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $editor = Utility::getCookieVar('publisher_editor');
                if (empty($editor) && \is_object($GLOBALS['xoopsUser'])) {
                    //                    $editor = @ $GLOBALS['xoopsUser']->getVar('publisher_editor'); // Need set through user profile
                    $editor = $GLOBALS['xoopsUser']->getVar('publisher_editor') ?? ''; // Need set through user profile
Severity: Minor
Found in class/Form/ItemForm.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\Utility' in method 'createElements'.
Open

            $wrapPages              = \XoopsLists::getHtmlListAsArray(Utility::getUploadDir(true, 'content'));
Severity: Minor
Found in class/Form/ItemForm.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 addElement uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $formElement->required = true;
                }
Severity: Minor
Found in class/Form/ThemeTabForm.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 createElements uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $catlist = $imgcatHandler->getList($group, 'imgcat_read', 1);
            }
Severity: Minor
Found in class/Form/ItemForm.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\Utility' in method 'wrapPage'.
Open

        $page    = Utility::getUploadDir(true, 'content') . $fileName;
Severity: Minor
Found in class/Item.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 '$size'.
Open

            $datesub_datetime = new FormDateTime(\_CO_PUBLISHER_DATESUB, 'datesub', $size = 15, $datesub, true, true);
Severity: Minor
Found in class/Form/ItemForm.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

Severity
Category
Status
Source
Language