YetiForceCompany/YetiForceCRM

View on GitHub
modules/Calendar/views/ActivityStateModal.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

Method getLinks has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getLinks(): array
    {
        $links = [];
        if ($this->record->isEditable() && \App\Mail::checkInternalMailClient()) {
            $links[] = Vtiger_Link_Model::getInstanceFromValues([
Severity: Minor
Found in modules/Calendar/views/ActivityStateModal.php - About 1 hr to fix

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

                throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

    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 'Vtiger_Record_Model' in method 'checkPermission'.
    Open

            $this->record = $request->isEmpty('record', true) ? null : Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule());

    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[] = Vtiger_Link_Model::getInstanceFromValues([
                    'linklabel' => 'LBL_SEND_CALENDAR',
                    'linkdata' => ['url' => "index.php?module={$this->record->getModuleName()}&view=SendInvitationModal&record={$this->record->getId()}"],
                    'linkicon' => 'yfi-send-invitation',
                    'linkclass' => 'btn-outline-dark btn-sm js-show-modal',

    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[] = Vtiger_Link_Model::getInstanceFromValues([
                    'linklabel' => 'LBL_EDIT',
                    'linkurl' => $this->record->getEditViewUrl(),
                    'linkicon' => 'yfi yfi-full-editing-view',
                    'linkclass' => 'btn-sm btn-default',

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

            if ($this->record->isEditable() && \App\Mail::checkInternalMailClient()) {

    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[] = Vtiger_Link_Model::getInstanceFromValues([
                    'linklabel' => 'LBL_SHOW_COMPLETE_DETAILS',
                    'linkurl' => $this->record->getDetailViewUrl(),
                    'linkicon' => 'fas fa-th-list',
                    'linkclass' => 'btn-sm btn-default',

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

                    'linklabel' => 'LBL_SEND_CALENDAR',

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

                    'linkclass' => 'btn-outline-dark btn-sm js-show-modal',

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

                    'linkicon' => 'yfi-send-invitation',

    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 \Vtiger_Viewer::assign
    Open

            $viewer->assign('SCRIPTS', $this->getScripts($request));

    Reference to undeclared property \Calendar_ActivityStateModal_View->record
    Open

            if ($this->record->isViewable()) {

    Reference to undeclared property \Calendar_ActivityStateModal_View->record
    Open

            if ($this->record->isEditable()) {

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('RECORD', $this->record);

    Reference to undeclared property \Calendar_ActivityStateModal_View->record
    Open

            if ($this->record->isEditable() && \App\Mail::checkInternalMailClient()) {

    Reference to undeclared property \Calendar_ActivityStateModal_View->record
    Open

                    'linkurl' => $this->record->getDetailViewUrl(),

    Reference to undeclared property \Calendar_ActivityStateModal_View->record
    Open

            $this->record = $request->isEmpty('record', true) ? null : Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule());

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('LINKS', $this->getLinks());

    Reference to undeclared property \Calendar_ActivityStateModal_View->record
    Open

                    'linkurl' => $this->record->getEditViewUrl(),

    Reference to undeclared property \Calendar_ActivityStateModal_View->record
    Open

                    'linkdata' => ['url' => "index.php?module={$this->record->getModuleName()}&view=SendInvitationModal&record={$this->record->getId()}"],

    Reference to undeclared property \Calendar_ActivityStateModal_View->record
    Open

            $viewer->assign('RECORD', $this->record);

    Reference to undeclared property \Calendar_ActivityStateModal_View->record
    Open

            if (!$this->record || !$this->record->isEditable()) {

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

    class Calendar_ActivityStateModal_View extends Vtiger_BasicModal_View

    The class Calendar_ActivityStateModal_View is not named in CamelCase.
    Open

    class Calendar_ActivityStateModal_View extends Vtiger_BasicModal_View
    {
        /**
         * Get tpl path file.
         *

    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

            $this->record = $request->isEmpty('record', true) ? null : Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule());

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

            $viewer->view($this->getTpl(), $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

                    'linklabel' => 'LBL_EDIT',

    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\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

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

            $viewer->assign('SCRIPTS', $this->getScripts($request));

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

        public function getLinks(): array

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

            $links = [];

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

                $links[] = Vtiger_Link_Model::getInstanceFromValues([

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

            if ($this->record->isViewable()) {

    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

        /** {@inheritdoc} */

    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

        public function getScripts(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

            return $this->checkAndConvertJsScripts([

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

                    'linkurl' => $this->record->getDetailViewUrl(),

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

                    'linkclass' => 'btn-sm btn-default',

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

            $moduleName = $request->getModule();

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

                $links[] = Vtiger_Link_Model::getInstanceFromValues([

    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

         *

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

         * @return array

    Line exceeds 120 characters; contains 150 characters
    Open

                    'linkdata' => ['url' => "index.php?module={$this->record->getModuleName()}&view=SendInvitationModal&record={$this->record->getId()}"],

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

            if (!$this->record || !$this->record->isEditable()) {

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

        }

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

                    'linklabel' => 'LBL_SEND_CALENDAR',

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

                    'linkclass' => 'btn-outline-dark btn-sm js-show-modal',

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

                    'linklabel' => 'LBL_SHOW_COMPLETE_DETAILS',

    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

        }

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

                    'linkurl' => $this->record->getEditViewUrl(),

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

        protected function getTpl()

    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-sm btn-default',

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

         * Get tpl path file.

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

            $viewer->assign('LINKS', $this->getLinks());

    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

            $viewer->assign('RECORD', $this->record);

    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

         * Gets links.

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

                    'linkicon' => 'yfi-send-invitation',

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

            if ($this->record->isEditable()) {

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

            return 'ActivityStateModal.tpl';

    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 = $this->getViewer($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

        }

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

                    'linkdata' => ['url' => "index.php?module={$this->record->getModuleName()}&view=SendInvitationModal&record={$this->record->getId()}"],

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

                $links[] = Vtiger_Link_Model::getInstanceFromValues([

    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

            if ($this->record->isEditable() && \App\Mail::checkInternalMailClient()) {

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

                ]);

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

                    'linkicon' => 'fas fa-th-list',

    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

        public function process(App\Request $request)

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

        {

    Line exceeds 120 characters; contains 159 characters
    Open

            $this->record = $request->isEmpty('record', true) ? null : Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule());

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

                'modules.' . $request->getModule() . '.resources.ActivityStateModal'

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

    class Calendar_ActivityStateModal_View extends Vtiger_BasicModal_View

    There are no issues that match your filters.

    Category
    Status