YetiForceCompany/YetiForceCRM

View on GitHub
modules/KnowledgeBase/models/DetailView.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

Method getDetailViewLinks has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getDetailViewLinks(array $linkParams): array
    {
        if ($this->getRecord()->isReadOnly() || \App\RequestUtil::getBrowserInfo()->ie) {
            return parent::getDetailViewLinks($linkParams);
        }
Severity: Minor
Found in modules/KnowledgeBase/models/DetailView.php - About 1 hr to fix

    Avoid using static access to class '\App\Language' in method 'getDetailViewLinks'.
    Open

                    'title' => \App\Language::translate('LBL_GO_TO_PREVIEW', $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 '\App\Language' in method 'getDetailViewLinks'.
    Open

                    'linkhint' => \App\Language::translate('LBL_GO_TO_PREVIEW', $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 'getDetailViewLinks'.
    Open

                $relatedLinks[] = Vtiger_Link_Model::getInstanceFromValues($relatedLinkEntry);

    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_DetailView_Model
    Open

                return parent::getDetailViewLinks($linkParams);

    Call to undeclared method \KnowledgeBase_DetailView_Model::getRecord
    Open

            if ($this->getRecord()->isReadOnly() || \App\RequestUtil::getBrowserInfo()->ie) {

    Call to undeclared method \KnowledgeBase_DetailView_Model::getRecord
    Open

            $recordModel = $this->getRecord();

    Reference to undeclared class \Vtiger_DetailView_Model
    Open

            $linkModelList = parent::getDetailViewLinks($linkParams);

    Class extends undeclared class \Vtiger_DetailView_Model
    Open

    class KnowledgeBase_DetailView_Model extends Vtiger_DetailView_Model

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

    class KnowledgeBase_DetailView_Model extends Vtiger_DetailView_Model

    The class KnowledgeBase_DetailView_Model is not named in CamelCase.
    Open

    class KnowledgeBase_DetailView_Model extends Vtiger_DetailView_Model
    {
        /** {@inheritdoc} */
        public function getDetailViewLinks(array $linkParams): array
        {

    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

                    ],

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

            foreach ($relatedLinks as $relatedLink) {

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

            $recordModel = $this->getRecord();

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

            $relatedLinkEntries = [

    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 $linkModelList;

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

                        'id' => $recordModel->getId(),

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

                    'linkhint' => \App\Language::translate('LBL_GO_TO_PREVIEW', $moduleName),

    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

            $moduleName = $recordModel->getModuleName();

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

                return parent::getDetailViewLinks($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' => [

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

                ],

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

            $linkModelList = parent::getDetailViewLinks($linkParams);

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

            if ($this->getRecord()->isReadOnly() || \App\RequestUtil::getBrowserInfo()->ie) {

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

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

    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

                        'module-name' => $moduleName

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

                    'vueId' => 'ArticlePreview',

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

                $linkModelList[$relatedLink->getType()][] = $relatedLink;

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

            foreach ($relatedLinkEntries as $relatedLinkEntry) {

    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 getDetailViewLinks(array $linkParams): array

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

                    'linkicon' => 'fas fa-expand',

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

                    'title' => \App\Language::translate('LBL_GO_TO_PREVIEW', $moduleName),

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

                $relatedLinks[] = Vtiger_Link_Model::getInstanceFromValues($relatedLinkEntry);

    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

                    'linktype' => 'DETAIL_VIEW_ADDITIONAL',

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

            $relatedLinks = [];

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

    class KnowledgeBase_DetailView_Model extends Vtiger_DetailView_Model

    There are no issues that match your filters.

    Category
    Status