YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

        return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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 getSearchParams uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $values = Calendar_Module_Model::getComponentActivityStateLabel('current');
        }
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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 '\App\Json' in method 'getWidget'.
Open

                $this->Config['switchTypeInHeader']['off'] = \App\Json::encode($this->getSearchParams('history'));
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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 '\App\Relation' in method 'isPermitted'.
Open

        return parent::isPermitted() && \App\Relation::getByModule($this->moduleModel->getName(), true, 'Calendar');
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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_Module_Model' in method 'getWidget'.
Open

        $model = Vtiger_Module_Model::getInstance('Calendar');
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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 '\App\Language' in method 'getWidget'.
Open

                $this->Config['switchHeaderLables']['on'] = \App\Language::translate('LBL_CURRENT', $model->getName());
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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 '\App\Language' in method 'getWidget'.
Open

                $this->Config['switchHeaderLables']['off'] = \App\Language::translate('LBL_HISTORY', $model->getName());
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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 'Calendar_Module_Model' in method 'getSearchParams'.
Open

            $values = Calendar_Module_Model::getComponentActivityStateLabel('current');
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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 'Calendar_Module_Model' in method 'getSearchParams'.
Open

            $values = Calendar_Module_Model::getComponentActivityStateLabel('history');
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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 '\App\Json' in method 'getWidget'.
Open

                $this->Config['switchTypeInHeader']['on'] = \App\Json::encode($this->getSearchParams('current'));
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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 'App\Json' in method 'getUrl'.
Open

        return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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 "switchTypeInHeader" 5 times.
Open

            if (!isset($this->Data['switchTypeInHeader']) || '-' != $this->Data['switchTypeInHeader']) {
Severity: Critical
Found in modules/Vtiger/widgets/Activities.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 "current" 3 times.
Open

        return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
Severity: Critical
Found in modules/Vtiger/widgets/Activities.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 "history" 3 times.
Open

                $this->Config['switchTypeInHeader']['off'] = \App\Json::encode($this->getSearchParams('history'));
Severity: Critical
Found in modules/Vtiger/widgets/Activities.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.

Reference to undeclared property \Vtiger_Activities_Widget->Data
Open

        return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
Severity: Minor
Found in modules/Vtiger/widgets/Activities.php by phan

Argument 2 (moduleName) is false but \App\Language::translate() takes string defined at /code/app/Language.php:161
Open

                $this->Config['switchHeaderLables']['on'] = \App\Language::translate('LBL_CURRENT', $model->getName());
Severity: Minor
Found in modules/Vtiger/widgets/Activities.php by phan

Call to method getName on non-class type false
Open

        return parent::isPermitted() && \App\Relation::getByModule($this->moduleModel->getName(), true, 'Calendar');
Severity: Critical
Found in modules/Vtiger/widgets/Activities.php by phan

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

        return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
Severity: Minor
Found in modules/Vtiger/widgets/Activities.php by phan

Reference to undeclared property \Vtiger_Activities_Widget->Data
Open

            if (!isset($this->Data['switchTypeInHeader']) || '-' != $this->Data['switchTypeInHeader']) {
Severity: Minor
Found in modules/Vtiger/widgets/Activities.php by phan

Argument 2 (moduleName) is false but \App\Language::translate() takes string defined at /code/app/Language.php:161
Open

                $this->Config['switchHeaderLables']['off'] = \App\Language::translate('LBL_HISTORY', $model->getName());
Severity: Minor
Found in modules/Vtiger/widgets/Activities.php by phan

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

class Vtiger_Activities_Widget extends Vtiger_Basic_Widget

The class Vtiger_Activities_Widget is not named in CamelCase.
Open

class Vtiger_Activities_Widget extends Vtiger_Basic_Widget
{
    /** {@inheritdoc} */
    public function isPermitted(): bool
    {
Severity: Minor
Found in modules/Vtiger/widgets/Activities.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

        return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);

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

                $this->Config['switchTypeInHeader'] = [];

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

     *

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 getWidget()

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

    {

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

     * Get URL.

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['switchTypeInHeader']['on'] = \App\Json::encode($this->getSearchParams('current'));

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

                $this->Config['switchHeaderLables']['off'] = \App\Language::translate('LBL_HISTORY', $model->getName());

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 [['activitystatus', 'e', implode('##', $values)]];

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

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

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

            $values = Calendar_Module_Model::getComponentActivityStateLabel('history');

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

    public function getUrl()

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

     * @param string $type

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

     */

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

        return 'ActivitiesConfig';

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

    public function isPermitted(): bool

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

        return parent::isPermitted() && \App\Relation::getByModule($this->moduleModel->getName(), true, 'Calendar');

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

        } else {

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

            if (!isset($this->Data['switchTypeInHeader']) || '-' != $this->Data['switchTypeInHeader']) {

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

                $this->Config['switchHeaderLables']['on'] = \App\Language::translate('LBL_CURRENT', $model->getName());

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 getSearchParams(string $type): array

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

                $this->Config['switchTypeInHeader']['off'] = \App\Json::encode($this->getSearchParams('history'));

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

     *  Function to get params to searching.

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

        }

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

    }

Line exceeds 120 characters; contains 300 characters
Open

        return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);

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

        $model = Vtiger_Module_Model::getInstance('Calendar');

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

    /**

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

     *

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

            $values = Calendar_Module_Model::getComponentActivityStateLabel('current');

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 ('history' === $type) {

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

class Vtiger_Activities_Widget extends Vtiger_Basic_Widget

There are no issues that match your filters.

Category
Status