YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
C
1 day
Test Coverage
F
0%

Method getDetailViewRelatedLinks has 103 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getDetailViewRelatedLinks()
    {
        $recordModel = $this->getRecord();
        $moduleName = $recordModel->getModuleName();
        $parentModuleModel = $this->getModule();
Severity: Major
Found in modules/Accounts/models/DetailView.php - About 4 hrs to fix

    Function getDetailViewRelatedLinks has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getDetailViewRelatedLinks()
        {
            $recordModel = $this->getRecord();
            $moduleName = $recordModel->getModuleName();
            $parentModuleModel = $this->getModule();
    Severity: Minor
    Found in modules/Accounts/models/DetailView.php - About 2 hrs 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

    Consider simplifying this complex logical expression.
    Open

                if (isset($relations['Products']) || isset($relations['Services']) || isset($relations['OSSOutsourcedServices']) || isset($relations['Assets']) || isset($relations['OSSSoldServices']) || isset($relations['OutsourcedProducts'])) {
                    $relatedLinks[] = [
                        'linktype' => 'DETAILVIEWTAB',
                        'linklabel' => 'LBL_RECORD_SUMMARY_PRODUCTS_SERVICES',
                        'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRelatedProductsServices&requestMode=summary',
    Severity: Major
    Found in modules/Accounts/models/DetailView.php - About 40 mins to fix

      The method getDetailViewRelatedLinks() has 107 lines of code. Current threshold is set to 100. Avoid really long methods.
      Open

          public function getDetailViewRelatedLinks()
          {
              $recordModel = $this->getRecord();
              $moduleName = $recordModel->getModuleName();
              $parentModuleModel = $this->getModule();

      The method getDetailViewRelatedLinks() has an NPath complexity of 38880. The configured NPath complexity threshold is 200.
      Open

          public function getDetailViewRelatedLinks()
          {
              $recordModel = $this->getRecord();
              $moduleName = $recordModel->getModuleName();
              $parentModuleModel = $this->getModule();

      NPathComplexity

      Since: 0.1

      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

      Example

      class Foo {
          function bar() {
              // lots of complicated code
          }
      }

      Source https://phpmd.org/rules/codesize.html#npathcomplexity

      The method getDetailViewRelatedLinks() has a Cyclomatic Complexity of 27. The configured cyclomatic complexity threshold is 10.
      Open

          public function getDetailViewRelatedLinks()
          {
              $recordModel = $this->getRecord();
              $moduleName = $recordModel->getModuleName();
              $parentModuleModel = $this->getModule();

      CyclomaticComplexity

      Since: 0.1

      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

      Example

      // Cyclomatic Complexity = 11
      class Foo {
      1   public function example() {
      2       if ($a == $b) {
      3           if ($a1 == $b1) {
                      fiddle();
      4           } elseif ($a2 == $b2) {
                      fiddle();
                  } else {
                      fiddle();
                  }
      5       } elseif ($c == $d) {
      6           while ($c == $d) {
                      fiddle();
                  }
      7        } elseif ($e == $f) {
      8           for ($n = 0; $n < $h; $n++) {
                      fiddle();
                  }
              } else {
                  switch ($z) {
      9               case 1:
                          fiddle();
                          break;
      10              case 2:
                          fiddle();
                          break;
      11              case 3:
                          fiddle();
                          break;
                      default:
                          fiddle();
                          break;
                  }
              }
          }
      }

      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

      Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed.
      Open

          public function getDetailViewRelatedLinks()

      Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

      See

      Avoid using static access to class 'App\Config' in method 'getDetailViewRelatedLinks'.
      Open

                      'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'),

      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_Relation_Model' in method 'getDetailViewRelatedLinks'.
      Open

                  $relations = \Vtiger_Relation_Model::getAllRelations($parentModuleModel, false, true, true, '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\Config' in method 'getDetailViewRelatedLinks'.
      Open

                          'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'),

      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\ModuleHierarchy' in method 'getDetailViewRelatedLinks'.
      Open

                  && false !== \App\ModuleHierarchy::getModuleLevel($parentModuleModel->getName())

      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

                  && \App\Module::isModuleActive('Chat') && !\App\RequestUtil::getBrowserInfo()->ie

      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($moduleName, 'SHOW_SUMMARY_PRODUCTS_SERVICES')) {

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

                  \App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()

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

                  \App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()

      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 '126', column '91').
      Open

          public function getDetailViewRelatedLinks()
          {
              $recordModel = $this->getRecord();
              $moduleName = $recordModel->getModuleName();
              $parentModuleModel = $this->getModule();

      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 'Vtiger_Module_Model' in method 'getDetailViewRelatedLinks'.
      Open

              $modCommentsModel = Vtiger_Module_Model::getInstance('ModComments');

      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

                      'countRelated' => App\Config::module('ModTracker', 'UNREVIEWED_COUNT') && $parentModuleModel->isPermitted('ReviewingUpdates'),

      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 'getDetailViewRelatedLinks'.
      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 'Vtiger_Link_Model' in method 'getDetailViewLinks'.
      Open

                  $linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues($massActionLink);

      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 "DETAILVIEWTAB" 8 times.
      Open

                      'linktype' => 'DETAILVIEWTAB',

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

                      'linkurl' => 'javascript:Vtiger_Detail_Js.triggerTransferOwnership("index.php?module=' . $this->getModule()->getName() . '&view=TransferOwnership&record=' . $this->record->getId() . '")',

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

                      'linkicon' => 'yfi yfi-change-of-owner',

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

                      'linklabel' => 'LBL_TRANSFER_OWNERSHIP',

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

                      'linktype' => 'DETAIL_VIEW_BASIC',

      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 "linkKey" 4 times.
      Open

                      'linkKey' => 'LBL_RECORD_PROCESS_WIZARD',

      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 "related" 6 times.
      Open

                      'related' => 'Summary',

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

                          'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'),

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

              if ($parentModuleModel->isTrackingEnabled() && $parentModuleModel->isPermitted('ModTracker')) {

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

                      'linklabel' => 'LBL_RECORD_SUMMARY',

      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 \Accounts_DetailView_Model::getModule
      Open

                      'linkurl' => 'javascript:Vtiger_Detail_Js.triggerTransferOwnership("index.php?module=' . $this->getModule()->getName() . '&view=TransferOwnership&record=' . $this->record->getId() . '")',
      Severity: Critical
      Found in modules/Accounts/models/DetailView.php by phan

      Call to undeclared method \Accounts_DetailView_Model::getModule
      Open

              if ($this->getRecord()->isEditable() && $this->getModule()->isPermitted('DetailTransferOwnership')) {
      Severity: Critical
      Found in modules/Accounts/models/DetailView.php by phan

      Call to undeclared method \Accounts_DetailView_Model::getWidgets
      Open

              $this->getWidgets();
      Severity: Critical
      Found in modules/Accounts/models/DetailView.php by phan

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

                  \App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()
      Severity: Critical
      Found in modules/Accounts/models/DetailView.php by phan

      Class extends undeclared class \Vtiger_DetailView_Model
      Open

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

      Reference to undeclared class \Vtiger_DetailView_Model
      Open

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

      Call to undeclared method \Accounts_DetailView_Model::getRecord
      Open

              if ($this->getRecord()->isEditable() && $this->getModule()->isPermitted('DetailTransferOwnership')) {
      Severity: Critical
      Found in modules/Accounts/models/DetailView.php by phan

      Call to undeclared method \Accounts_DetailView_Model::getRecord
      Open

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

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

              if ($userPrivilegesModel->hasModulePermission('OpenStreetMap')) {
      Severity: Minor
      Found in modules/Accounts/models/DetailView.php by phan

      Call to undeclared method \Accounts_DetailView_Model::getModule
      Open

              $parentModuleModel = $this->getModule();
      Severity: Critical
      Found in modules/Accounts/models/DetailView.php by phan

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

                  \App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()
      Severity: Critical
      Found in modules/Accounts/models/DetailView.php by phan

      Reference to undeclared property \Accounts_DetailView_Model->widgetsList
      Open

              if ($parentModuleModel->isSummaryViewSupported() && $this->widgetsList) {
      Severity: Minor
      Found in modules/Accounts/models/DetailView.php by phan

      Reference to undeclared property \Accounts_DetailView_Model->record
      Open

                      'linkurl' => 'javascript:Vtiger_Detail_Js.triggerTransferOwnership("index.php?module=' . $this->getModule()->getName() . '&view=TransferOwnership&record=' . $this->record->getId() . '")',
      Severity: Minor
      Found in modules/Accounts/models/DetailView.php by phan

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

                  if (isset($relations['Products']) || isset($relations['Services']) || isset($relations['OSSOutsourcedServices']) || isset($relations['Assets']) || isset($relations['OSSSoldServices']) || isset($relations['OutsourcedProducts'])) {
                      $relatedLinks[] = [
                          'linktype' => 'DETAILVIEWTAB',
                          'linklabel' => 'LBL_RECORD_SUMMARY_PRODUCTS_SERVICES',
                          'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRelatedProductsServices&requestMode=summary',
      Severity: Major
      Found in modules/Accounts/models/DetailView.php and 1 other location - About 1 hr to fix
      modules/SSalesProcesses/models/DetailView.php on lines 20..30

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 120.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              foreach ($parentModuleModel->getRelations() as $relation) {
                  if ($relation->isRelatedViewType('RelatedTab') && (!$relation->isDirectRelation() || !($relationField = $relation->getRelationField()) || $relationField->isActiveField())) {
                      $relatedLinks[] = [
                          'linktype' => 'DETAILVIEWRELATED',
                          'linklabel' => $relation->get('label'),
      Severity: Major
      Found in modules/Accounts/models/DetailView.php and 1 other location - About 1 hr to fix
      modules/Vtiger/models/DetailView.php on lines 416..427

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 110.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              if (
                  \App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()
                  && \App\Module::isModuleActive('Chat') && !\App\RequestUtil::getBrowserInfo()->ie
                  && false !== \App\ModuleHierarchy::getModuleLevel($parentModuleModel->getName())
              ) {
      Severity: Minor
      Found in modules/Accounts/models/DetailView.php and 1 other location - About 55 mins to fix
      modules/Vtiger/models/DetailView.php on lines 404..415

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 98.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              if ($parentModuleModel->isTrackingEnabled() && $parentModuleModel->isPermitted('ModTracker')) {
                  $relatedLinks[] = [
                      'linktype' => 'DETAILVIEWTAB',
                      'linklabel' => 'LBL_UPDATES',
                      'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRecentActivities&page=1',
      Severity: Minor
      Found in modules/Accounts/models/DetailView.php and 1 other location - About 30 mins to fix
      modules/Vtiger/models/DetailView.php on lines 393..403

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 90.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      class Accounts_DetailView_Model extends Vtiger_DetailView_Model

      The class Accounts_DetailView_Model is not named in CamelCase.
      Open

      class Accounts_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

              $parentModuleModel = $this->getModule();

      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' => $recordModel->getDetailViewUrl() . '&mode=showDetailViewByMode&requestMode=full',

      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

                          'linkicon' => '',

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

                          'related' => 'ProductsAndServices',

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

                          'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'),

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

                  && \App\Module::isModuleActive('Chat') && !\App\RequestUtil::getBrowserInfo()->ie

      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

          }

      Line exceeds 120 characters; contains 203 characters
      Open

                      'linkurl' => 'javascript:Vtiger_Detail_Js.triggerTransferOwnership("index.php?module=' . $this->getModule()->getName() . '&view=TransferOwnership&record=' . $this->record->getId() . '")',

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

                      'related' => 'Summary',

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

              //link which shows the summary information(generally detail of record)

      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_TRANSFER_OWNERSHIP',

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

                      'linkurl' => 'javascript:Vtiger_Detail_Js.triggerTransferOwnership("index.php?module=' . $this->getModule()->getName() . '&view=TransferOwnership&record=' . $this->record->getId() . '")',

      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' => '',

      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

                      'linktype' => 'DETAIL_VIEW_BASIC',

      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

              if (class_exists($parentModuleModel->getName() . '_ProcessWizard_Model') && $recordModel->isEditable()) {

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

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

      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

                  'related' => 'Details',

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

                      'countRelated' => App\Config::module('ModTracker', 'UNREVIEWED_COUNT') && $parentModuleModel->isPermitted('ReviewingUpdates'),

      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

                          'linkicon' => '',

      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' => 'LBL_RECORD_SUMMARY',

      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' => 'DETAILVIEWTAB',

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

              if (App\Config::module($moduleName, 'SHOW_SUMMARY_PRODUCTS_SERVICES')) {

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

                  $relations = \Vtiger_Relation_Model::getAllRelations($parentModuleModel, false, true, true, 'modulename');

      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=showRelatedProductsServices&requestMode=summary',

      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

              }

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

                      'linklabel' => 'LBL_RECORD_PROCESS_WIZARD',

      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' => 'DETAILVIEWTAB',

      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

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

      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

              $modCommentsModel = Vtiger_Module_Model::getInstance('ModComments');

      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

                  if ($relation->isRelatedViewType('RelatedTab') && (!$relation->isDirectRelation() || !($relationField = $relation->getRelationField()) || $relationField->isActiveField())) {

      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

              return $linkModelList;

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

                      'linkKey' => 'LBL_RECORD_PROCESS_WIZARD',

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

              if ($parentModuleModel->isCommentEnabled() && $modCommentsModel->isPermitted('DetailView')) {

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

              }

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

                      'related' => 'ModTracker',

      Line exceeds 120 characters; contains 142 characters
      Open

                      'countRelated' => App\Config::module('ModTracker', 'UNREVIEWED_COUNT') && $parentModuleModel->isPermitted('ReviewingUpdates'),

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

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

      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-comments',

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

                          'relatedModuleName' => $relation->get('relatedModuleName'),

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

              if ($this->getRecord()->isEditable() && $this->getModule()->isPermitted('DetailTransferOwnership')) {

      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

                      'linkKey' => 'LBL_RECORD_SUMMARY',

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

                      'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showDetailViewByMode&requestMode=summary',

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

                      'related' => 'Summary',

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

                  if (isset($relations['Products']) || isset($relations['Services']) || isset($relations['OSSOutsourcedServices']) || isset($relations['Assets']) || isset($relations['OSSSoldServices']) || isset($relations['OutsourcedProducts'])) {

      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 (

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

                  && false !== \App\ModuleHierarchy::getModuleLevel($parentModuleModel->getName())

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

                          'relationId' => $relation->getId(),

      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

                  $relatedLinks[] = [

      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

              ];

      Line exceeds 120 characters; contains 241 characters
      Open

                  if (isset($relations['Products']) || isset($relations['Services']) || isset($relations['OSSOutsourcedServices']) || isset($relations['Assets']) || isset($relations['OSSSoldServices']) || isset($relations['OutsourcedProducts'])) {

      Line exceeds 120 characters; contains 124 characters
      Open

                          'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRelatedProductsServices&requestMode=summary',

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

                      'related' => $modCommentsModel->getName(),

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

              if ($parentModuleModel->isTrackingEnabled() && $parentModuleModel->isPermitted('ModTracker')) {

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

                      'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRecentActivities&page=1',

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

                      'badgeClass' => 'bgDanger',

      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

                      'linktype' => 'DETAILVIEWTAB',

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

                  \App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()

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

              foreach ($parentModuleModel->getRelations() as $relation) {

      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

                  'linklabel' => 'LBL_RECORD_DETAILS',

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

                  'linkKey' => 'LBL_RECORD_DETAILS',

      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' => '',

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

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

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

                  $massActionLink = [

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

                      'linkicon' => 'yfi yfi-change-of-owner',

      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

                          'linklabel' => 'LBL_RECORD_SUMMARY_PRODUCTS_SERVICES',

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

                      'linklabel' => 'LBL_CHAT',

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

                          'linktype' => 'DETAILVIEWRELATED',

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

          }

      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

                      'linktype' => 'DETAILVIEWTAB',

      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

                      'linklabel' => 'ModComments',

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

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

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

                      'linklabel' => 'LBL_UPDATES',

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

              if ($userPrivilegesModel->hasModulePermission('OpenStreetMap')) {

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

                          'linklabel' => $relation->get('label'),

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

                          'linkurl' => $relation->getListUrl($recordModel),

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

      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

          {

      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($massActionLink);

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

              if ($parentModuleModel->isSummaryViewSupported() && $this->widgetsList) {

      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_MAP',

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

                      ];

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

              $this->getWidgets();

      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

                          'linkKey' => 'LBL_RECORD_SUMMARY',

      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' => 'DETAILVIEWTAB',

      Line exceeds 120 characters; contains 185 characters
      Open

                  if ($relation->isRelatedViewType('RelatedTab') && (!$relation->isDirectRelation() || !($relationField = $relation->getRelationField()) || $relationField->isActiveField())) {

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

                      'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'),

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

              $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

      class Accounts_DetailView_Model extends Vtiger_DetailView_Model

      Expected 0 spaces after opening bracket; newline found
      Open

              if (

      There are no issues that match your filters.

      Category
      Status