YetiForceCompany/YetiForceCRM

View on GitHub
modules/Rss/models/Module.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using undefined variables such as '$records' which will lead to PHP notices.
Open

        return $records;
Severity: Minor
Found in modules/Rss/models/Module.php by phpmd

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

Avoid using undefined variables such as '$records' which will lead to PHP notices.
Open

            $records[$row['id']] = $this->getRecordFromArray($row);
Severity: Minor
Found in modules/Rss/models/Module.php by phpmd

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

Missing class import via use statement (line '44', column '22').
Open

        $dataReader = (new \App\Db\Query())->from('vtiger_rss')->createCommand()->query();
Severity: Minor
Found in modules/Rss/models/Module.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

Avoid using static access to class 'Vtiger_Link_Model' in method 'getSideBarLinks'.
Open

        $links['SIDEBARWIDGET'][] = Vtiger_Link_Model::getInstanceFromValues([
            'linktype' => 'SIDEBARWIDGET',
            'linklabel' => 'LBL_RSS_FEED_SOURCES',
            'linkurl' => 'module=' . $this->getName() . '&view=ViewTypes&mode=getRssWidget',
            'linkicon' => '',
Severity: Minor
Found in modules/Rss/models/Module.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 'Vtiger_Link_Model' in method 'getSideBarLinks'.
Open

        $links['SIDEBARLINK'][] = Vtiger_Link_Model::getInstanceFromValues([
            'linktype' => 'SIDEBARLINK',
            'linklabel' => 'LBL_ADD_FEED_SOURCE',
            'linkurl' => $this->getDefaultUrl(),
            'linkicon' => 'fas fa-rss',
Severity: Minor
Found in modules/Rss/models/Module.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 'Vtiger_Link_Model' in method 'getSideBarLinks'.
Open

        $links = Vtiger_Link_Model::getAllByType($this->getId(), ['SIDEBARLINK', 'SIDEBARWIDGET'], $linkParams);
Severity: Minor
Found in modules/Rss/models/Module.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

Define a constant instead of duplicating this literal "SIDEBARLINK" 3 times.
Open

        $links = Vtiger_Link_Model::getAllByType($this->getId(), ['SIDEBARLINK', 'SIDEBARWIDGET'], $linkParams);
Severity: Critical
Found in modules/Rss/models/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "SIDEBARWIDGET" 3 times.
Open

        $links = Vtiger_Link_Model::getAllByType($this->getId(), ['SIDEBARLINK', 'SIDEBARWIDGET'], $linkParams);
Severity: Critical
Found in modules/Rss/models/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Saw unextractable annotation for comment '* @param <array> $linkParams'</array>
Open

     * @param <Array> $linkParams
Severity: Info
Found in modules/Rss/models/Module.php by phan

Variable $records was undeclared, but array fields are being added to it.
Open

            $records[$row['id']] = $this->getRecordFromArray($row);
Severity: Info
Found in modules/Rss/models/Module.php by phan

Saw unextractable annotation for comment '* @return <array> List of Vtiger_Link_Model instances'</array>
Open

     * @return <Array> List of Vtiger_Link_Model instances
Severity: Info
Found in modules/Rss/models/Module.php by phan

Call to undeclared method \App\Db\Query::from
Open

        $dataReader = (new \App\Db\Query())->from('vtiger_rss')->createCommand()->query();
Severity: Critical
Found in modules/Rss/models/Module.php by phan

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Rss_Module_Model extends Vtiger_Module_Model

The class Rss_Module_Model is not named in CamelCase.
Open

class Rss_Module_Model extends Vtiger_Module_Model
{
    /**
     * Function to get the Quick Links for the module.
     *
Severity: Minor
Found in modules/Rss/models/Module.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

        $dataReader = (new \App\Db\Query())->from('vtiger_rss')->createCommand()->query();

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            'linkicon' => '',

Spaces must be used to indent lines; tabs are not allowed
Open

        while ($row = $dataReader->read()) {

Spaces must be used to indent lines; tabs are not allowed
Open

        $dataReader->close();

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getSideBarLinks($linkParams)

Spaces must be used to indent lines; tabs are not allowed
Open

            'linkicon' => 'fas fa-rss',

Spaces must be used to indent lines; tabs are not allowed
Open

            'linktype' => 'SIDEBARWIDGET',

Spaces must be used to indent lines; tabs are not allowed
Open

            'linkurl' => 'module=' . $this->getName() . '&view=ViewTypes&mode=getRssWidget',

Spaces must be used to indent lines; tabs are not allowed
Open

        ]);

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getRssSources()

Spaces must be used to indent lines; tabs are not allowed
Open

            $records[$row['id']] = $this->getRecordFromArray($row);

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        $links = Vtiger_Link_Model::getAllByType($this->getId(), ['SIDEBARLINK', 'SIDEBARWIDGET'], $linkParams);

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        ]);

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get the Quick Links for the module.

Spaces must be used to indent lines; tabs are not allowed
Open

        $links['SIDEBARLINK'][] = Vtiger_Link_Model::getInstanceFromValues([

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return <Array> List of Vtiger_Link_Model instances

Spaces must be used to indent lines; tabs are not allowed
Open

            'linktype' => 'SIDEBARLINK',

Spaces must be used to indent lines; tabs are not allowed
Open

        $links['SIDEBARWIDGET'][] = Vtiger_Link_Model::getInstanceFromValues([

Spaces must be used to indent lines; tabs are not allowed
Open

            'linklabel' => 'LBL_RSS_FEED_SOURCES',

Spaces must be used to indent lines; tabs are not allowed
Open

        return $links;

Spaces must be used to indent lines; tabs are not allowed
Open

            $row['id'] = $row['rssid'];

Spaces must be used to indent lines; tabs are not allowed
Open

            'linklabel' => 'LBL_ADD_FEED_SOURCE',

Spaces must be used to indent lines; tabs are not allowed
Open

            'linkurl' => $this->getDefaultUrl(),

Spaces must be used to indent lines; tabs are not allowed
Open

        return $records;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param <Array> $linkParams

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get rss sources list.

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Class name "Rss_Module_Model" is not in camel caps format
Open

class Rss_Module_Model extends Vtiger_Module_Model

There are no issues that match your filters.

Category
Status