YetiForceCompany/YetiForceCRM

View on GitHub
modules/ModTracker/actions/Widget.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Missing class import via use statement (line '33', column '14').
Open

            throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');
Severity: Minor
Found in modules/ModTracker/actions/Widget.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 '51', column '19').
Open

        $response = new Vtiger_Response();
Severity: Minor
Found in modules/ModTracker/actions/Widget.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 'App\Json' in method 'saveUpdatesWidgetConfig'.
Open

        $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => App\Json::encode($data)],
Severity: Minor
Found in modules/ModTracker/actions/Widget.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_Widget_Model' in method 'checkPermission'.
Open

        $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetId'), \App\User::getCurrentUserId());
Severity: Minor
Found in modules/ModTracker/actions/Widget.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 'ModTracker' in method 'checkPermission'.
Open

        if (!$widget->get('active') || ($request->has('trackerActions') && array_diff($request->getArray('trackerActions', 'Integer'), array_keys(ModTracker::getAllActionsTypes())))) {
Severity: Minor
Found in modules/ModTracker/actions/Widget.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\User' in method 'saveUpdatesWidgetConfig'.
Open

        ['userid' => App\User::getCurrentUserId(), 'id' => $request->getInteger('widgetId')])
Severity: Minor
Found in modules/ModTracker/actions/Widget.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\User' in method 'checkPermission'.
Open

        $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetId'), \App\User::getCurrentUserId());
Severity: Minor
Found in modules/ModTracker/actions/Widget.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 "trackerActions" 4 times.
Open

        if (!$widget->get('active') || ($request->has('trackerActions') && array_diff($request->getArray('trackerActions', 'Integer'), array_keys(ModTracker::getAllActionsTypes())))) {
Severity: Critical
Found in modules/ModTracker/actions/Widget.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.

Call to undeclared method \App\Db::createCommand
Open

        $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => App\Json::encode($data)],
Severity: Critical
Found in modules/ModTracker/actions/Widget.php by phan

Call to method getInstanceWithWidgetId from undeclared class \Vtiger_Widget_Model
Open

        $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetId'), \App\User::getCurrentUserId());
Severity: Critical
Found in modules/ModTracker/actions/Widget.php by phan

Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

        ['userid' => App\User::getCurrentUserId(), 'id' => $request->getInteger('widgetId')])
Severity: Critical
Found in modules/ModTracker/actions/Widget.php by phan

Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

        $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetId'), \App\User::getCurrentUserId());
Severity: Critical
Found in modules/ModTracker/actions/Widget.php by phan

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

class ModTracker_Widget_Action extends \App\Controller\Action

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 15 and the first side effect is on line 11.
Open

<?php

The class ModTracker_Widget_Action is not named in CamelCase.
Open

class ModTracker_Widget_Action extends \App\Controller\Action
{
    use \App\Controller\ExposeMethod;

    /**
Severity: Minor
Found in modules/ModTracker/actions/Widget.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

Only one argument is allowed per line in a multi-line function call
Open

        $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => App\Json::encode($data)],

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

            throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');

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

        if (!$widget->get('active') || ($request->has('trackerActions') && array_diff($request->getArray('trackerActions', 'Integer'), array_keys(ModTracker::getAllActionsTypes())))) {

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

        $owner = $request->getByType('owner', 2);

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

            ->execute();

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

     */

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

    use \App\Controller\ExposeMethod;

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

        $this->exposeMethod('saveUpdatesWidgetConfig');

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

        $response = new Vtiger_Response();

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

        $data = ['actions' => $actions, 'owner' => $owner, 'historyOwner' => $historyOwner];

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

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

        }

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

     * Save updates widget config.

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

    public function saveUpdatesWidgetConfig(App\Request $request)

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

        $response->emit();

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

    }

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

        parent::__construct();

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

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

    {

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

        $actions = $request->has('trackerActions') ? $request->getArray('trackerActions', 'Integer') : [];

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

     * Constructor.

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

     */

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

        $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetId'), \App\User::getCurrentUserId());

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

     *

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

        ['userid' => App\User::getCurrentUserId(), 'id' => $request->getInteger('widgetId')])

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

    public function __construct()

Line exceeds 120 characters; contains 128 characters
Open

        $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetId'), \App\User::getCurrentUserId());

Line exceeds 120 characters; contains 184 characters
Open

        if (!$widget->get('active') || ($request->has('trackerActions') && array_diff($request->getArray('trackerActions', 'Integer'), array_keys(ModTracker::getAllActionsTypes())))) {

Line exceeds 120 characters; contains 144 characters
Open

        $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['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

        $response->setResult($result);

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

        $historyOwner = $request->getByType('historyOwner', 2);

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

        $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => App\Json::encode($data)],

Opening parenthesis of a multi-line function call must be the last content on the line
Open

        $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => App\Json::encode($data)],

Closing parenthesis of a multi-line function call must be on a line by itself
Open

        ['userid' => App\User::getCurrentUserId(), 'id' => $request->getInteger('widgetId')])

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

class ModTracker_Widget_Action extends \App\Controller\Action

There are no issues that match your filters.

Category
Status