mambax7/publisher

View on GitHub

Showing 3,032 of 3,032 total issues

Missing class import via use statement (line '355', column '32').
Open

            $criteria->add(new \Criteria('rate', 1));
Severity: Minor
Found in class/VoteHandler.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Missing class import via use statement (line '429', column '28').
Open

        $criteria->add(new \Criteria(static::SOURCE, $source));
Severity: Minor
Found in class/VoteHandler.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Missing class import via use statement (line '184', column '32').
Open

            $criteria->add(new \Criteria(static::SOURCE, $source));
Severity: Minor
Found in class/VoteHandler.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Missing class import via use statement (line '203', column '32').
Open

            $criteria->add(new \Criteria(static::IDENTIFIER, $itemId));
Severity: Minor
Found in class/VoteHandler.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Missing class import via use statement (line '310', column '32').
Open

            $criteria->add(new \Criteria('rate', 0, '<'));
Severity: Minor
Found in class/VoteHandler.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Missing class import via use statement (line '185', column '32').
Open

            $criteria->add(new \Criteria('rate', 0, '<'));
Severity: Minor
Found in class/VoteHandler.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Function handleResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function handleResponse() {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {

            var response = xmlhttp.responseText;
Severity: Minor
Found in assets/js/rating.js - About 25 mins to fix

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 editFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function editFile($showmenu = false, $fileid = 0, $itemId = 0): void
    {
        $helper = Helper::getInstance();
        require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');

Severity: Minor
Found in class/Utility.php - About 25 mins to fix

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 getOrderBy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getOrderBy($sort)
    {
        if ('datesub' === $sort) {
            return 'DESC';
        }
Severity: Minor
Found in class/Utility.php - About 25 mins to fix

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 getPathStatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getPathStatus($item, $getStatus = false)
    {
        $path = '';
        if ('root' !== $item) {
            $path = $item;
Severity: Minor
Found in class/Utility.php - About 25 mins to fix

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 notNullFieldClause has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function notNullFieldClause($notNullFields = '', $withAnd = false)
    {
        $ret = '';
        if ($withAnd) {
            $ret .= ' AND ';
Severity: Minor
Found in class/ItemHandler.php - About 25 mins to fix

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 convertIPAddresses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function convertIPAddresses($tableName, $columnName): void
    {
        if ($this->tableHandler->useTable($tableName)) {
            $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName);
            if (false !== \mb_strpos($attributes, ' int(')) {
Severity: Minor
Found in class/Common/Migrate.php - About 25 mins to fix

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 getObjects has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function &getObjects($criteria = null, $idAsKey = false, $asObject = true) //&getObjects($criteria = null, $idAsKey = false)
    {
        $ret   = [];
        $limit = $start = 0;
        $sql   = $this->selectQuery($criteria);
Severity: Minor
Found in class/BaseObjectHandler.php - About 25 mins to fix

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 selectQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function selectQuery($criteria = null, $join = false)
    {
        //        if (!$join) {
        //            $sql = sprintf('SELECT * FROM `%s`', $this->db->prefix($this->dbtable));
        //        } else {
Severity: Minor
Found in class/MimetypeHandler.php - About 25 mins to fix

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 getTitle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getTitle($maxLength = 0, $format = 'S')
    {
        $ret = $this->getVar('title', $format);
        if (0 != $maxLength) {
            if (!XOOPS_USE_MULTIBYTES) {
Severity: Minor
Found in class/Item.php - About 25 mins to fix

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 sendNotifications has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function sendNotifications($notifications = []): void
    {
        /** @var \XoopsNotificationHandler $notificationHandler */
        $notificationHandler = \xoops_getHandler('notification');
        $tags                = [];
Severity: Minor
Found in class/Item.php - About 25 mins to fix

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 getSubtitle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSubtitle($maxLength = 0, $format = 'S')
    {
        $ret = $this->getVar('subtitle', $format);
        if (0 != $maxLength) {
            if (!XOOPS_USE_MULTIBYTES) {
Severity: Minor
Found in class/Item.php - About 25 mins to fix

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 createLogo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function createLogo($dirname)
    {
        if (!\extension_loaded('gd')) {
            return false;
        }
Severity: Minor
Found in class/Cloner.php - About 25 mins to fix

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 static access to class '\Xmf\Yaml' in method 'loadSampleData'.
Open

        $tabledata = Yaml::readWrapped($language . $table . '.yml');
Severity: Minor
Found in testdata/index.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 loadTableFromArrayWithReplace uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $insertInto  .= ', ';
                $valueClause .= ', ';
            }
Severity: Minor
Found in testdata/index.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

Severity
Category
Status
Source
Language