YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/actions/Search.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

Method owners has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function owners(App\Request $request)
    {
        $owner = App\Fields\Owner::getInstance();
        $owner->showRoleName = true;
        $owner->find($request->getByType('value', 'Text'));
Severity: Minor
Found in modules/Vtiger/actions/Search.php - About 1 hr to fix

    Function owners has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function owners(App\Request $request)
        {
            $owner = App\Fields\Owner::getInstance();
            $owner->showRoleName = true;
            $owner->find($request->getByType('value', 'Text'));
    Severity: Minor
    Found in modules/Vtiger/actions/Search.php - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Missing class import via use statement (line '73', column '19').
    Open

            $response = new Vtiger_Response();
    Severity: Minor
    Found in modules/Vtiger/actions/Search.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 '25', column '14').
    Open

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
    Severity: Minor
    Found in modules/Vtiger/actions/Search.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\User' in method 'owners'.
    Open

    }
    Severity: Minor
    Found in modules/Vtiger/actions/Search.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 'owners'.
    Open

                        'category' => \App\Language::translate('LBL_GROUP'),
    Severity: Minor
    Found in modules/Vtiger/actions/Search.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\Fields\Owner' in method 'owners'.
    Open

            $owner = App\Fields\Owner::getInstance();
    Severity: Minor
    Found in modules/Vtiger/actions/Search.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 'owners'.
    Open

                    $imageUrl = \App\User::getImageById($key) ? \App\User::getImageById($key)['url'] : '';
    Severity: Minor
    Found in modules/Vtiger/actions/Search.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 assigning values to variables in if clauses and the like (line '47', column '7').
    Open

        public function owners(App\Request $request)
        {
            $owner = App\Fields\Owner::getInstance();
            $owner->showRoleName = true;
            $owner->find($request->getByType('value', 'Text'));
    Severity: Minor
    Found in modules/Vtiger/actions/Search.php by phpmd

    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 '\App\Language' in method 'owners'.
    Open

                        'category' => \App\Language::translate('LBL_USER'),
    Severity: Minor
    Found in modules/Vtiger/actions/Search.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 'Users_Privileges_Model' in method 'checkPermission'.
    Open

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
    Severity: Minor
    Found in modules/Vtiger/actions/Search.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

    Argument 1 (mixed) is string but \Users_Privileges_Model::hasModulePermission() takes int defined at /code/modules/Users/models/Privileges.php:101
    Open

            if (!$userPrivilegesModel->hasModulePermission($request->getModule())) {
    Severity: Minor
    Found in modules/Vtiger/actions/Search.php by phan

    Call to method getInstance from undeclared class \App\Fields\Owner
    Open

            $owner = App\Fields\Owner::getInstance();
    Severity: Critical
    Found in modules/Vtiger/actions/Search.php by phan

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

                    $imageUrl = \App\User::getImageById($key) ? \App\User::getImageById($key)['url'] : '';
    Severity: Critical
    Found in modules/Vtiger/actions/Search.php by phan

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

    class Vtiger_Search_Action extends \App\Controller\Action

    The class Vtiger_Search_Action is not named in CamelCase.
    Open

    class Vtiger_Search_Action extends \App\Controller\Action
    {
        use \App\Controller\ExposeMethod;
    
        /** {@inheritdoc} */
    Severity: Minor
    Found in modules/Vtiger/actions/Search.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

            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

         * Search owners.

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

            $owner->showRoleName = true;

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

                    $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

                }

    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

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

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

                foreach ($users as $key => $value) {

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

                        'image' => $imageUrl ?? '',

    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 (!$userPrivilegesModel->hasModulePermission($request->getModule())) {

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

            if ($users = $owner->getAccessibleUsers('private', 'owner')) {

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

                        'module' => 'Groups',

    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

                        'module' => 'Users',

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

            $response->setResult($data);

    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

        public function checkPermission(App\Request $request)

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

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

            $data = [];

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

                        'image' => '',

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

            $owner->find($request->getByType('value', 'Text'));

    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

            $this->exposeMethod('owners');

    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

            $owner = App\Fields\Owner::getInstance();

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

            }

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

            $group = $owner->getAccessibleGroups('private', 'owner', true);

    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

                foreach ($group as $key => $value) {

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

                    $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

            }

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

        public function __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

                        'category' => \App\Language::translate('LBL_GROUP'),

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

                        'label' => $value,

    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

         */

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

                        'category' => \App\Language::translate('LBL_USER'),

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

                        'label' => $value,

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

            if (!empty($group)) {

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

                    $imageUrl = \App\User::getImageById($key) ? \App\User::getImageById($key)['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

                        'id' => $key,

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

        {

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

                        'id' => $key,

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

                        'icon' => $imageUrl ? '' : 'yfi yfi-users-2'

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

                        'icon' => 'adminIcon-groups'

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

        public function owners(App\Request $request)

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

    class Vtiger_Search_Action extends \App\Controller\Action

    There are no issues that match your filters.

    Category
    Status