YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/widgets/RelatedModuleChart.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class 'Vtiger_Module_Model' in method 'getWidget'.
Open

        $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);

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\Module' in method 'getUrl'.
Open

        $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

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 'getUrl'.
Open

        $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showCharts&relatedModule=' . $moduleName . '&chartType=' . $this->Data['chartType'] . '&valueType=' . $this->Data['valueType'] . '&relationId=' . $this->Data['relation_id'] . '&widgetId=' . $this->Config['id'] . '&search_params=' . App\Json::encode([$this->getSearchParams()]);

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 "relatedmodule" 4 times.
Open

        $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

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 property \Vtiger_RelatedModuleChart_Widget->Data
Open

            $params = array_merge($params, $this->Data['search_params']);

Suspicious type null of a variable or expression used to build a string. (Expected type to be able to cast to a string)
Open

        $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showCharts&relatedModule=' . $moduleName . '&chartType=' . $this->Data['chartType'] . '&valueType=' . $this->Data['valueType'] . '&relationId=' . $this->Data['relation_id'] . '&widgetId=' . $this->Config['id'] . '&search_params=' . App\Json::encode([$this->getSearchParams()]);

Reference to undeclared property \Vtiger_RelatedModuleChart_Widget->Data
Open

        if (!empty($this->Data['search_params'])) {

Reference to undeclared property \Vtiger_RelatedModuleChart_Widget->Data
Open

            $url .= '&no_result_text=' . $this->Data['no_result_text'];

Reference to undeclared property \Vtiger_RelatedModuleChart_Widget->Data
Open

        $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showCharts&relatedModule=' . $moduleName . '&chartType=' . $this->Data['chartType'] . '&valueType=' . $this->Data['valueType'] . '&relationId=' . $this->Data['relation_id'] . '&widgetId=' . $this->Config['id'] . '&search_params=' . App\Json::encode([$this->getSearchParams()]);

Reference to undeclared property \Vtiger_RelatedModuleChart_Widget->Data
Open

            $url .= '&valueField=' . $this->Data['valueField'];

Reference to undeclared property \Vtiger_RelatedModuleChart_Widget->Data
Open

        if (isset($this->Data['no_result_text'])) {

Invalid offset "id" of array type array{}
Open

        $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showCharts&relatedModule=' . $moduleName . '&chartType=' . $this->Data['chartType'] . '&valueType=' . $this->Data['valueType'] . '&relationId=' . $this->Data['relation_id'] . '&widgetId=' . $this->Config['id'] . '&search_params=' . App\Json::encode([$this->getSearchParams()]);

Reference to undeclared property \Vtiger_RelatedModuleChart_Widget->Data
Open

        if (!empty($this->Data['valueField'])) {

Suspicious type false of a variable or expression used to build a string. (Expected type to be able to cast to a string)
Open

        $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showCharts&relatedModule=' . $moduleName . '&chartType=' . $this->Data['chartType'] . '&valueType=' . $this->Data['valueType'] . '&relationId=' . $this->Data['relation_id'] . '&widgetId=' . $this->Config['id'] . '&search_params=' . App\Json::encode([$this->getSearchParams()]);

Reference to undeclared property \Vtiger_RelatedModuleChart_Widget->Data
Open

        $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);

Reference to undeclared property \Vtiger_RelatedModuleChart_Widget->Data
Open

        $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

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

class Vtiger_RelatedModuleChart_Widget extends Vtiger_Basic_Widget

The class Vtiger_RelatedModuleChart_Widget is not named in CamelCase.
Open

class Vtiger_RelatedModuleChart_Widget extends Vtiger_Basic_Widget
{
    /**
     * Gets URL.
     *

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

        if (isset($this->Data['no_result_text'])) {

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

    /**

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

        if (!empty($this->Data['valueField'])) {

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

        return $url;

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

        return $widget;

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

        if (!empty($this->Data['search_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

    public function getConfigTplName()

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

        }

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

        $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);

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 string

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

        if ($model->isPermitted('DetailView')) {

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

     * @return array

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

    public function getSearchParams(): array

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

    public function getUrl(): string

Line exceeds 120 characters; contains 152 characters
Open

        $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

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

            $this->Config['url'] = $this->getUrl();

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

    public function getWidget()

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

        $widget = [];

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

            $this->Config['tpl'] = 'Basic.tpl';

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

        return $params;

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

    }

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

     * Gets URL.

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 = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

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

        $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showCharts&relatedModule=' . $moduleName . '&chartType=' . $this->Data['chartType'] . '&valueType=' . $this->Data['valueType'] . '&relationId=' . $this->Data['relation_id'] . '&widgetId=' . $this->Config['id'] . '&search_params=' . App\Json::encode([$this->getSearchParams()]);

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

            $url .= '&valueField=' . $this->Data['valueField'];

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

            $widget = $this->Config;

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

        $params = [];

Line exceeds 120 characters; contains 368 characters
Open

        $url = 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showCharts&relatedModule=' . $moduleName . '&chartType=' . $this->Data['chartType'] . '&valueType=' . $this->Data['valueType'] . '&relationId=' . $this->Data['relation_id'] . '&widgetId=' . $this->Config['id'] . '&search_params=' . App\Json::encode([$this->getSearchParams()]);

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 params to searching.

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 'RelatedModuleChartConfig';

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

    {

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

            $params = array_merge($params, $this->Data['search_params']);

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

    {

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

            $url .= '&no_result_text=' . $this->Data['no_result_text'];

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

     */

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

    /**

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

class Vtiger_RelatedModuleChart_Widget extends Vtiger_Basic_Widget

There are no issues that match your filters.

Category
Status