YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/dashboards/RssModel.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class '\App\Json' in method 'setDataFromRequest'.
Open

            $data = $this->get('data') ? \App\Json::decode($this->get('data')) : [];

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 '\App\Json' in method 'getFieldInstanceByName'.
Open

                $owners = $this->get('data') ? \App\Json::decode($this->get('data')) : [];

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 '\App\Json' in method 'setDataFromRequest'.
Open

            $this->set('data', \App\Json::encode($data));

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_Field_Model' in method 'getFieldInstanceByName'.
Open

        return \Vtiger_Field_Model::init($moduleName, $params, $name);

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 "channels" 3 times.
Open

        if (!isset($this->customFields[$name]) && 'channels' !== $name) {

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.

Reference to undeclared class \Vtiger_Widget_Model
Open

        parent::setDataFromRequest($request);
Severity: Critical
Found in modules/Vtiger/dashboards/RssModel.php by phan

Class extends undeclared class \Vtiger_Widget_Model
Open

class Vtiger_RssModel_Dashboard extends Vtiger_Widget_Model
Severity: Critical
Found in modules/Vtiger/dashboards/RssModel.php by phan

Reference to undeclared class \Vtiger_Widget_Model
Open

            return parent::getFieldInstanceByName($name);
Severity: Critical
Found in modules/Vtiger/dashboards/RssModel.php by phan

Call to undeclared method \Vtiger_RssModel_Dashboard::get
Open

            $data = $this->get('data') ? \App\Json::decode($this->get('data')) : [];
Severity: Critical
Found in modules/Vtiger/dashboards/RssModel.php by phan

Reference to undeclared property \Vtiger_RssModel_Dashboard->customFields
Open

        if (!isset($this->customFields[$name]) && 'channels' !== $name) {
Severity: Minor
Found in modules/Vtiger/dashboards/RssModel.php by phan

Call to undeclared method \Vtiger_RssModel_Dashboard::set
Open

            $this->set('data', \App\Json::encode($data));
Severity: Critical
Found in modules/Vtiger/dashboards/RssModel.php by phan

Reference to undeclared property \Vtiger_RssModel_Dashboard->editFields
Open

        return ['title' => ['label' => 'LBL_WIDGET_NAME', 'purifyType' => \App\Purifier::TEXT, 'required' => true]] + $this->editFields;
Severity: Minor
Found in modules/Vtiger/dashboards/RssModel.php by phan

Call to undeclared method \Vtiger_RssModel_Dashboard::get
Open

                $owners = $this->get('data') ? \App\Json::decode($this->get('data')) : [];
Severity: Critical
Found in modules/Vtiger/dashboards/RssModel.php by phan

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

class Vtiger_RssModel_Dashboard extends Vtiger_Widget_Model

The class Vtiger_RssModel_Dashboard is not named in CamelCase.
Open

class Vtiger_RssModel_Dashboard extends Vtiger_Widget_Model
{
    /** {@inheritdoc} */
    public function getEditFields(): array
    {

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

The DEFAULT body must start on the line following the statement
Open

            default: break;

Terminating statement must be on a line by itself
Open

            default: break;

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

        $moduleName = 'Settings:WidgetsManagement';

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

                $params['picklistValues'] = [];

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

                $params['typeofdata'] = 'V~M';

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

    /** {@inheritdoc} */

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

        $params = [

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

    /** {@inheritdoc} */

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

    {

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

            $data[$fieldName] = $value;

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

        if (!isset($this->customFields[$name]) && 'channels' !== $name) {

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

            $value = $value ? explode(' |##| ', $value) : [];

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

    /** {@inheritdoc} */

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

            'label' => 'LBL_ADDRESS_RSS',

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

                break;

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

            $fieldModel = $this->getFieldInstanceByName($fieldName)->getUITypeModel();

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

        return ['title' => ['label' => 'LBL_WIDGET_NAME', 'purifyType' => \App\Purifier::TEXT, 'required' => true]] + $this->editFields;

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

    public function getFieldInstanceByName($name)

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

        switch ($name) {

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

                $params['fieldvalue'] = implode(' |##| ', $value);

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

        parent::setDataFromRequest($request);

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

            $this->set('data', \App\Json::encode($data));

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

                $owners = $this->get('data') ? \App\Json::decode($this->get('data')) : [];

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

            return parent::getFieldInstanceByName($name);

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

                $params['uitype'] = 33;

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

    {

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

                $value = $owners[$name] ?? [];

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

            default: break;

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

        $fieldName = 'channels';

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

            $value = $request->getByType($fieldName, \App\Purifier::TEXT);

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

    public function getEditFields(): array

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

        return \Vtiger_Field_Model::init($moduleName, $params, $name);

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 setDataFromRequest(App\Request $request)

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

            $fieldModel->validate($value, true);

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

    {

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

            'name' => $name,

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

            'tooltip' => ''

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

        if ($request->has($fieldName)) {

Line exceeds 120 characters; contains 136 characters
Open

        return ['title' => ['label' => 'LBL_WIDGET_NAME', 'purifyType' => \App\Purifier::TEXT, 'required' => true]] + $this->editFields;

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

            case 'channels':

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

    }

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

            $value = $fieldModel->getDBValue($value);

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

            $data = $this->get('data') ? \App\Json::decode($this->get('data')) : [];

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

        ];

Closing brace must be on a line by itself
Open

            default: break;

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

class Vtiger_RssModel_Dashboard extends Vtiger_Widget_Model

There are no issues that match your filters.

Category
Status