YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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

    public function getDetailViewLinks(array $linkParams): array
    {
        $recordModel = $this->getRecord();
        $linkModelList = parent::getDetailViewLinks($linkParams);
        if (!$recordModel->isReadOnly()) {
Severity: Minor
Found in modules/Project/models/DetailView.php - About 1 hr to fix

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

                if (\App\Privilege::isPermitted('ProjectTask', 'EditView')) {
    Severity: Minor
    Found in modules/Project/models/DetailView.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\Privilege' in method 'getDetailViewLinks'.
    Open

                if (\App\Privilege::isPermitted('Documents', 'EditView')) {
    Severity: Minor
    Found in modules/Project/models/DetailView.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\Config' in method 'getDetailViewRelatedLinks'.
    Open

            if (\App\Config::module('Project', 'showGanttTab', true) && \App\Module::isModuleActive('ProjectTask') && \App\Module::isModuleActive('ProjectMilestone')) {
    Severity: Minor
    Found in modules/Project/models/DetailView.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\Module' in method 'getDetailViewRelatedLinks'.
    Open

            if (\App\Config::module('Project', 'showGanttTab', true) && \App\Module::isModuleActive('ProjectTask') && \App\Module::isModuleActive('ProjectMilestone')) {
    Severity: Minor
    Found in modules/Project/models/DetailView.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 'getDetailViewRelatedLinks'.
    Open

                    'linklabel' => \App\Language::translate('LBL_GANTT', $moduleName),
    Severity: Minor
    Found in modules/Project/models/DetailView.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 'Vtiger_Link_Model' in method 'getDetailViewLinks'.
    Open

                    $linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([
                        'linktype' => 'DETAIL_VIEW_BASIC',
                        'linklabel' => 'Add Project Task',
                        'linkurl' => "index.php?module=ProjectTask&action=EditView&projectid={$recordId}&return_module=Project&return_action=DetailView&return_id={$recordId}",
                        'linkicon' => 'fas fa-tasks',
    Severity: Minor
    Found in modules/Project/models/DetailView.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\Module' in method 'getDetailViewRelatedLinks'.
    Open

            if (\App\Config::module('Project', 'showGanttTab', true) && \App\Module::isModuleActive('ProjectTask') && \App\Module::isModuleActive('ProjectMilestone')) {
    Severity: Minor
    Found in modules/Project/models/DetailView.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 'Vtiger_Link_Model' in method 'getDetailViewLinks'.
    Open

                    $linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([
                        'linktype' => 'DETAIL_VIEW_BASIC',
                        'linklabel' => 'Add Note',
                        'linkurl' => "index.php?module=Documents&action=EditView&return_module=Project&return_action=DetailView&return_id={$recordId}&parent_id={$recordId}",
                        'linkicon' => 'fas fa-file',
    Severity: Minor
    Found in modules/Project/models/DetailView.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

    Define a constant instead of duplicating this literal "DETAIL_VIEW_BASIC" 4 times.
    Open

                    $linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([
    Severity: Critical
    Found in modules/Project/models/DetailView.php by sonar-php

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

                        'linklabel' => 'Add Project Task',
    Severity: Critical
    Found in modules/Project/models/DetailView.php by sonar-php

    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' => 'fas fa-tasks',
    Severity: Critical
    Found in modules/Project/models/DetailView.php by sonar-php

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

                        'linktype' => 'DETAIL_VIEW_BASIC',
    Severity: Critical
    Found in modules/Project/models/DetailView.php by sonar-php

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

                        'linkurl' => "index.php?module=ProjectTask&action=EditView&projectid={$recordId}&return_module=Project&return_action=DetailView&return_id={$recordId}",
    Severity: Critical
    Found in modules/Project/models/DetailView.php by sonar-php

    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.

    Class extends undeclared class \Vtiger_DetailView_Model
    Open

    class Project_DetailView_Model extends Vtiger_DetailView_Model
    Severity: Critical
    Found in modules/Project/models/DetailView.php by phan

    Call to undeclared method \Project_DetailView_Model::getRecord
    Open

            $recordModel = $this->getRecord();
    Severity: Critical
    Found in modules/Project/models/DetailView.php by phan

    Reference to undeclared class \Vtiger_DetailView_Model
    Open

            $linkModelList = parent::getDetailViewLinks($linkParams);
    Severity: Critical
    Found in modules/Project/models/DetailView.php by phan

    Reference to undeclared class \Vtiger_DetailView_Model
    Open

            $relatedLinks = parent::getDetailViewRelatedLinks();
    Severity: Critical
    Found in modules/Project/models/DetailView.php by phan

    Call to undeclared method \Project_DetailView_Model::getRecord
    Open

            $recordModel = $this->getRecord();
    Severity: Critical
    Found in modules/Project/models/DetailView.php by phan

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

    class Project_DetailView_Model extends Vtiger_DetailView_Model

    The class Project_DetailView_Model is not named in CamelCase.
    Open

    class Project_DetailView_Model extends Vtiger_DetailView_Model
    {
        /** {@inheritdoc} */
        public function getDetailViewLinks(array $linkParams): array
        {
    Severity: Minor
    Found in modules/Project/models/DetailView.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

                    $linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([

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

                        'linkhint' => 'Add Project Task',

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

                        'linkurl' => "index.php?module=Documents&action=EditView&return_module=Project&return_action=DetailView&return_id={$recordId}&parent_id={$recordId}",

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

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

    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

                        'linklabel' => 'Add Note',

    Line exceeds 120 characters; contains 171 characters
    Open

                        'linkurl' => "index.php?module=ProjectTask&action=EditView&projectid={$recordId}&return_module=Project&return_action=DetailView&return_id={$recordId}",

    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['DETAIL_VIEW_BASIC'][] = 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

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

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

                        'linkurl' => "index.php?module=ProjectTask&action=EditView&projectid={$recordId}&return_module=Project&return_action=DetailView&return_id={$recordId}",

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

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

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

                        'linkclass' => 'btn-outline-dark btn-sm'

    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

                $recordId = $recordModel->getId();

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

                if (\App\Privilege::isPermitted('Documents', 'EditView')) {

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

                        'linkclass' => 'btn-outline-dark btn-sm'

    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 (!$recordModel->isReadOnly()) {

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

                if (\App\Privilege::isPermitted('ProjectTask', 'EditView')) {

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

                        'linktype' => 'DETAIL_VIEW_BASIC',

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

                        'linklabel' => 'Add Project Task',

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

                        'linkhint' => 'Add Note',

    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

                        'linktype' => 'DETAIL_VIEW_BASIC',

    Line exceeds 120 characters; contains 169 characters
    Open

                        'linkurl' => "index.php?module=Documents&action=EditView&return_module=Project&return_action=DetailView&return_id={$recordId}&parent_id={$recordId}",

    Line exceeds 120 characters; contains 164 characters
    Open

            if (\App\Config::module('Project', 'showGanttTab', true) && \App\Module::isModuleActive('ProjectTask') && \App\Module::isModuleActive('ProjectMilestone')) {

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

                    'linkKey' => 'LBL_GANTT',

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

                    'linkicon' => '',

    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 getDetailViewRelatedLinks()

    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

                    'linklabel' => \App\Language::translate('LBL_GANTT', $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

                $relatedLinks[] = [

    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

            $relatedLinks = parent::getDetailViewRelatedLinks();

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

                    'linktype' => 'DETAILVIEWTAB',

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

                    'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showGantt',

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

                    'related' => 'Gantt',

    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

            $moduleName = $recordModel->getModuleName();

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

            if (\App\Config::module('Project', 'showGanttTab', true) && \App\Module::isModuleActive('ProjectTask') && \App\Module::isModuleActive('ProjectMilestone')) {

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

            return $relatedLinks;

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

            $recordModel = $this->getRecord();

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

    class Project_DetailView_Model extends Vtiger_DetailView_Model

    There are no issues that match your filters.

    Category
    Status