YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/WidgetsManagement/views/EditWidget.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class '\Vtiger_Widget_Model' in method 'checkPermission'.
Open

            $this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('widgetId'));

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 '\vtlib\Link' in method 'checkPermission'.
Open

        if ($request->isEmpty('widgetId', true) && !$request->isEmpty('blockId', true) && $linkData = \vtlib\Link::getLinkData($request->getInteger('linkId'))) {

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 assigning values to variables in if clauses and the like (line '30', column '85').
Open

    public function checkPermission(App\Request $request)
    {
        parent::checkPermission($request);
        if ($request->isEmpty('widgetId', true) && !$request->isEmpty('blockId', true) && $linkData = \vtlib\Link::getLinkData($request->getInteger('linkId'))) {
            $linkData['blockid'] = $request->getInteger('blockId');

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Avoid using static access to class '\Vtiger_Widget_Model' in method 'checkPermission'.
Open

            $this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);

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 checkPermission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('widgetId'));
        }

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

Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->successBtnIcon
Open

        $viewer->assign('BTN_SUCCESS_ICON', $this->successBtnIcon);

Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->footerClass
Open

        $viewer->assign('FOOTER_CLASS', $this->footerClass);

Call to undeclared method \Settings_WidgetsManagement_EditWidget_View::getViewer
Open

        $viewer = $this->getViewer($request);

Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->widgetModel
Open

            $this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);

Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->widgetModel
Open

        $viewer->assign('WIDGET_MODEL', $this->widgetModel);

Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->widgetModel
Open

        return $this->widgetModel->getTranslatedTitle();

Call to method getInstanceWithTemplateId from undeclared class \Vtiger_Widget_Model
Open

            $this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('widgetId'));

Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->widgetModel
Open

            $this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('widgetId'));

Call to method getInstanceFromValues from undeclared class \Vtiger_Widget_Model
Open

            $this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);

Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->successBtn
Open

        $viewer->assign('BTN_SUCCESS', $this->successBtn);

Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->dangerBtn
Open

        $viewer->assign('BTN_DANGER', $this->dangerBtn);

Avoid excessively long class names like Settings_WidgetsManagement_EditWidget_View. Keep class name length under 40.
Open

class Settings_WidgetsManagement_EditWidget_View extends \App\Controller\ModalSettings
{
    /** {@inheritdoc} */
    public $modalIcon = 'adminIcon-widgets-configuration';

LongClassName

Since: 2.9

Detects when classes or interfaces are declared with excessively long names.

Example

class ATooLongClassNameThatHintsAtADesignProblem {

}

interface ATooLongInterfaceNameThatHintsAtADesignProblem {

}

Source https://phpmd.org/rules/naming.html#longclassname

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

class Settings_WidgetsManagement_EditWidget_View extends \App\Controller\ModalSettings

The class Settings_WidgetsManagement_EditWidget_View is not named in CamelCase.
Open

class Settings_WidgetsManagement_EditWidget_View extends \App\Controller\ModalSettings
{
    /** {@inheritdoc} */
    public $modalIcon = 'adminIcon-widgets-configuration';

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

    public $modalSize = 'modal-md';

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

        parent::checkPermission($request);

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

            $this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);

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

        $viewer->assign('BTN_SUCCESS', $this->successBtn);

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

        $viewer->assign('FOOTER_CLASS', $this->footerClass);

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

    public $showFooter = false;

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

    {

Line exceeds 120 characters; contains 161 characters
Open

        if ($request->isEmpty('widgetId', true) && !$request->isEmpty('blockId', true) && $linkData = \vtlib\Link::getLinkData($request->getInteger('linkId'))) {

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

        } else {

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

    public function process(App\Request $request)

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

        $viewer->assign('BTN_SUCCESS_ICON', $this->successBtnIcon);

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

            $linkData['blockid'] = $request->getInteger('blockId');

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

        }

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

        return $this->widgetModel->getTranslatedTitle();

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

        $viewer->view('EditWidget.tpl', $qualifiedModuleName);

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

    public $modalIcon = 'adminIcon-widgets-configuration';

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

    {

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

        $qualifiedModuleName = $request->getModule(false);

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

    /** {@inheritdoc} */

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

            $this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('widgetId'));

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

    }

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

        $viewer->assign('BTN_DANGER', $this->dangerBtn);

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

        $viewer = $this->getViewer($request);

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

        if ($request->isEmpty('widgetId', true) && !$request->isEmpty('blockId', true) && $linkData = \vtlib\Link::getLinkData($request->getInteger('linkId'))) {

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 getPageTitle(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

        $viewer->assign('WIDGET_MODEL', $this->widgetModel);

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

class Settings_WidgetsManagement_EditWidget_View extends \App\Controller\ModalSettings

There are no issues that match your filters.

Category
Status