YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/models/QuickCreateView.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Avoid using static access to class 'Vtiger_Link_Model' in method 'getLinks'.
Open

        $links = Vtiger_Link_Model::getAllByType($this->getModule()->getId(), ['QUICKCREATE_VIEW_HEADER', 'EDIT_VIEW_RECORD_COLLECTOR'], $linkParams);

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_Loader' in method 'getInstance'.
Open

        $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'QuickCreateView', $moduleName);

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

        $moduleModel = Vtiger_Module_Model::getInstance($moduleName);

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_Link_Model' in method 'getLinks'.
Open

        $links['QUICKCREATE_VIEW_HEADER'][] = Vtiger_Link_Model::getInstanceFromValues([
            'linktype' => 'QUICKCREATE_VIEW_HEADER',
            'linkhint' => 'LBL_GO_TO_FULL_FORM',
            'showLabel' => 1,
            'linkicon' => 'yfi yfi-full-editing-view',

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

        $links = Vtiger_Link_Model::getAllByType($this->getModule()->getId(), ['QUICKCREATE_VIEW_HEADER', 'EDIT_VIEW_RECORD_COLLECTOR'], $linkParams);

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.

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

class Vtiger_QuickCreateView_Model extends \App\Base

The class Vtiger_QuickCreateView_Model is not named in CamelCase.
Open

class Vtiger_QuickCreateView_Model extends \App\Base
{
    /**
     * Function to get the instance.
     *

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

     * Function to get the instance.

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

        return $links;

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

    }

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

        $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'QuickCreateView', $moduleName);

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

     * @return self

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

     *

Line exceeds 120 characters; contains 150 characters
Open

        $links = Vtiger_Link_Model::getAllByType($this->getModule()->getId(), ['QUICKCREATE_VIEW_HEADER', 'EDIT_VIEW_RECORD_COLLECTOR'], $linkParams);

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

    {

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

            'linkhint' => 'LBL_GO_TO_FULL_FORM',

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

     */

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

        $instance = new $modelClassName();

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

        $moduleModel = Vtiger_Module_Model::getInstance($moduleName);

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

            'linkclass' => 'btn-light js-full-editlink fontBold u-text-ellipsis mb-2 mb-md-0 col-12'

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

    public static function getInstance(string $moduleName)

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

    public function getLinks(array $linkParams)

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

            'linkicon' => 'yfi yfi-full-editing-view',

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 the Module Model.

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

            'linktype' => 'QUICKCREATE_VIEW_HEADER',

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

    public function getModule()

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

     * @return Vtiger_Link_Model[] - Associate array of Link Type to List of Vtiger_Link_Model instances

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 $instance->set('module', $moduleModel);

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

     * @return Vtiger_Module_Model instance

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

     * @param array $linkParams

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

     *

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

            'linkdata' => ['js' => 'click', 'url' => $this->getModule()->getCreateRecordUrl()],

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 $moduleName

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

     * @throws \App\Exceptions\AppException

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

    }

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

            'showLabel' => 1,

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

        $links['QUICKCREATE_VIEW_HEADER'][] = Vtiger_Link_Model::getInstanceFromValues([

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

        $links = Vtiger_Link_Model::getAllByType($this->getModule()->getId(), ['QUICKCREATE_VIEW_HEADER', 'EDIT_VIEW_RECORD_COLLECTOR'], $linkParams);

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

        return $this->get('module');

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 the list of links for the module.

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

     */

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

class Vtiger_QuickCreateView_Model extends \App\Base

There are no issues that match your filters.

Category
Status