YetiForceCompany/YetiForceCRM

View on GitHub
modules/ServiceContracts/views/Detail.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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

    public function showSlaPolicyView(App\Request $request)
    {
        $moduleName = $request->getModule();
        $relatedModuleName = $request->getByType('target', \App\Purifier::ALNUM);
        $rows = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'), \App\Module::getModuleId($relatedModuleName));
Severity: Minor
Found in modules/ServiceContracts/views/Detail.php - About 1 hr to fix

    Missing class import via use statement (line '32', column '15').
    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 'Users_Privileges_Model' in method 'checkPermission'.
    Open

                $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

    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\Utils\ServiceContracts' in method 'showSlaPolicyView'.
    Open

            $rows = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'), \App\Module::getModuleId($relatedModuleName));

    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\Module' in method 'showSlaPolicyView'.
    Open

            $rows = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'), \App\Module::getModuleId($relatedModuleName));

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

                    $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

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

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

    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\Utils\ServiceContracts' in method 'showSlaPolicyView'.
    Open

            $viewer->assign('ALL_BUSINESS_HOURS', \App\Utils\ServiceContracts::getAllBusinessHours());

    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

    Reference to undeclared class \Vtiger_Detail_View
    Open

            parent::__construct();
    Severity: Critical
    Found in modules/ServiceContracts/views/Detail.php by phan

    Reference to undeclared class \Vtiger_Detail_View
    Open

            parent::checkPermission($request);
    Severity: Critical
    Found in modules/ServiceContracts/views/Detail.php by phan

    Reference to undeclared property \ServiceContracts_Detail_View->record
    Open

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

    Call to undeclared method \ServiceContracts_Detail_View::getViewer
    Open

            $viewer = $this->getViewer($request);
    Severity: Critical
    Found in modules/ServiceContracts/views/Detail.php by phan

    Reference to undeclared property \ServiceContracts_Detail_View->record
    Open

                if (!$userPrivilegesModel->hasModuleActionPermission($this->record->getModuleName(), 'ServiceContractsSla') || !$userPrivilegesModel->hasModulePermission($request->getByType('target', \App\Purifier::ALNUM))) {

    Call to undeclared method \ServiceContracts_Detail_View::checkAndConvertJsScripts
    Open

                $this->checkAndConvertJsScripts([
    Severity: Critical
    Found in modules/ServiceContracts/views/Detail.php by phan

    Call to deprecated function \Vtiger_Field_Model::getFieldName() defined at /code/modules/Vtiger/models/Field.php:203
    Open

                    $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

    Class extends undeclared class \Vtiger_Detail_View
    Open

    class ServiceContracts_Detail_View extends Vtiger_Detail_View
    Severity: Critical
    Found in modules/ServiceContracts/views/Detail.php by phan

    Reference to undeclared class \Vtiger_Detail_View
    Open

                parent::getFooterScripts($request),
    Severity: Critical
    Found in modules/ServiceContracts/views/Detail.php by phan

    Call to undeclared method \ServiceContracts_Detail_View::exposeMethod
    Open

            $this->exposeMethod('showSlaPolicyView');
    Severity: Critical
    Found in modules/ServiceContracts/views/Detail.php by phan

    Avoid excessively long variable names like $recordStructureModulesField. Keep variable name length under 20.
    Open

            $recordStructureModulesField = [];

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

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

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

    class ServiceContracts_Detail_View extends Vtiger_Detail_View

    The class ServiceContracts_Detail_View is not named in CamelCase.
    Open

    class ServiceContracts_Detail_View extends Vtiger_Detail_View
    {
        /** {@inheritdoc} */
        public function __construct()
        {

    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

            $moduleName = $request->getModule();

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

            $viewer->assign('SLA_POLICY_ROWS', $rows);

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

            foreach ($moduleModel->getFieldsByReference() as $referenceField) {

    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

            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

        public function showSlaPolicyView(App\Request $request)

    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

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

    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

         * @throws \App\Exceptions\IllegalValue

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

        {

    Line exceeds 120 characters; contains 155 characters
    Open

            $rows = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'), \App\Module::getModuleId($relatedModuleName));

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

            $policyType = 0;

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

            $viewer->assign('VIEW', $request->getByType('view'));

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

            return array_merge(

    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 string

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

            $viewer->assign('MODULE', $moduleName);

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

            return $viewer->view('SlaPolicy.tpl', $moduleName, true);

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

            $viewer->assign('RECORD_STRUCTURE_RELATED_MODULES', $recordStructureModulesField);

    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

            parent::checkPermission($request);

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

            $rows = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'), \App\Module::getModuleId($relatedModuleName));

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

                parent::getFooterScripts($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

            }

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

            }

    Line exceeds 120 characters; contains 221 characters
    Open

                if (!$userPrivilegesModel->hasModuleActionPermission($this->record->getModuleName(), 'ServiceContractsSla') || !$userPrivilegesModel->hasModulePermission($request->getByType('target', \App\Purifier::ALNUM))) {

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

                    $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

    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

        }

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

            $viewer->assign('SOURCE_MODULE', $relatedModuleName);

    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->exposeMethod('showSlaPolicyView');

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

            if ('showSlaPolicyView' === $request->getMode()) {

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

                }

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

         * Show SLA Policy.

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

            if (isset($rows[0])) {

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

            $viewer->assign('POLICY_TYPE', $policyType);

    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

                if (!$userPrivilegesModel->hasModuleActionPermission($this->record->getModuleName(), 'ServiceContractsSla') || !$userPrivilegesModel->hasModulePermission($request->getByType('target', \App\Purifier::ALNUM))) {

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

            $recordStructureModulesField = [];

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

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

    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

                $policyType = (int) $rows[0]['policy_type'];

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

                foreach ($referenceField->getReferenceList() as $relatedModuleName) {

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

         *

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

            $relatedModuleName = $request->getByType('target', \App\Purifier::ALNUM);

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

        public function getFooterScripts(App\Request $request)

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

                $this->checkAndConvertJsScripts([

    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

         */

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

            $viewer->assign('ALL_BUSINESS_HOURS', \App\Utils\ServiceContracts::getAllBusinessHours());

    Line exceeds 120 characters; contains 221 characters
    Open

                    $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

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

            $viewer->assign('RECORD_STRUCTURE', Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel)->getStructure());

    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('TARGET_MODULE', $relatedModuleName);

    Line exceeds 120 characters; contains 126 characters
    Open

            $viewer->assign('RECORD_STRUCTURE', Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel)->getStructure());

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

                    'modules.ServiceContracts.resources.InRelation',

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

    class ServiceContracts_Detail_View extends Vtiger_Detail_View

    There are no issues that match your filters.

    Category
    Status