YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
B
5 hrs
Test Coverage
F
0%

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

    public function getDetailViewLinks(array $linkParams): array
    {
        $linkModelList = parent::getDetailViewLinks($linkParams);
        $recordModel = $this->getRecord();
        $moduleName = $recordModel->getModuleName();
Severity: Major
Found in modules/Calendar/models/DetailView.php - About 2 hrs to fix

    Function getDetailViewLinks has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getDetailViewLinks(array $linkParams): array
        {
            $linkModelList = parent::getDetailViewLinks($linkParams);
            $recordModel = $this->getRecord();
            $moduleName = $recordModel->getModuleName();
    Severity: Minor
    Found in modules/Calendar/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 ($recordModel->isEditable() && $this->getModule()->isPermitted('DetailView') && \App\Privilege::isPermitted($moduleName, 'ActivityComplete', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityCancel', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityPostponed', $recordId) && \in_array($recordModel->get('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {
                $linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues([
                    'linktype' => 'DETAIL_VIEW_BASIC',
                    'linklabel' => 'LBL_SET_RECORD_STATUS',
                    'linkurl' => '#',
    Severity: Major
    Found in modules/Calendar/models/DetailView.php - About 40 mins to fix

      The method getDetailViewLinks() has an NPath complexity of 4536. The configured NPath complexity threshold is 200.
      Open

          public function getDetailViewLinks(array $linkParams): array
          {
              $linkModelList = parent::getDetailViewLinks($linkParams);
              $recordModel = $this->getRecord();
              $moduleName = $recordModel->getModuleName();

      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 getDetailViewLinks() has a Cyclomatic Complexity of 23. The configured cyclomatic complexity threshold is 10.
      Open

          public function getDetailViewLinks(array $linkParams): array
          {
              $linkModelList = parent::getDetailViewLinks($linkParams);
              $recordModel = $this->getRecord();
              $moduleName = $recordModel->getModuleName();

      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 22 to the 15 allowed.
      Open

          public function getDetailViewLinks(array $linkParams): array

      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\Privilege' in method 'getDetailViewLinks'.
      Open

              if ($recordModel->isEditable() && $this->getModule()->isPermitted('DetailView') && \App\Privilege::isPermitted($moduleName, 'ActivityComplete', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityCancel', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityPostponed', $recordId) && \in_array($recordModel->get('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {

      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 ($recordModel->isEditable() && $this->getModule()->isPermitted('DetailView') && \App\Privilege::isPermitted($moduleName, 'ActivityComplete', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityCancel', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityPostponed', $recordId) && \in_array($recordModel->get('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {

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

                  $stateColors = App\Config::search('LIST_ENTITY_STATE_COLOR');

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

              if ($recordModel->isEditable() && $this->getModule()->isPermitted('DetailView') && \App\Privilege::isPermitted($moduleName, 'ActivityComplete', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityCancel', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityPostponed', $recordId) && \in_array($recordModel->get('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

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

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

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

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

              if (!$recordModel->isReadOnly() && !$recordModel->isEmpty('location') && App\Privilege::isPermitted('OpenStreetMap')) {

      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_EXTENDED'][] = Vtiger_Link_Model::getInstanceFromValues([
                      'linktype' => 'DETAIL_VIEW_EXTENDED',
                      'linklabel' => 'LBL_MOVE_TO_TRASH',
                      'linkurl' => 'javascript:Calendar_Detail_Js.deleteRecord("index.php?module=' . $recordModel->getModuleName() . '&action=State&state=Trash&record=' . $recordModel->getId() . '")',
                      'linkicon' => 'fas fa-trash-alt',

      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

                      'title' => \App\Language::translate('LBL_MOVE_TO_TRASH'),

      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

                      'title' => \App\Language::translate('LBL_DELETE_RECORD_COMPLETELY'),

      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 ($recordModel->isEditable() && $this->getModule()->isPermitted('DetailView') && \App\Privilege::isPermitted($moduleName, 'ActivityComplete', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityCancel', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityPostponed', $recordId) && \in_array($recordModel->get('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {

      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' => 'LBL_SET_RECORD_STATUS',
                      'linkurl' => '#',
                      'linkdata' => ['url' => $recordModel->getActivityStateModalUrl()],

      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_ADDITIONAL'][] = Vtiger_Link_Model::getInstanceFromValues([
                      'linktype' => 'DETAIL_VIEW_ADDITIONAL',
                      'linklabel' => 'LBL_SEND_CALENDAR',
                      'linkdata' => ['url' => "index.php?module={$moduleName}&view=SendInvitationModal&record={$recordId}"],
                      'linkicon' => 'yfi-send-invitation',

      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_EXTENDED'][] = Vtiger_Link_Model::getInstanceFromValues([
                      'linktype' => 'DETAIL_VIEW_EXTENDED',
                      'linklabel' => 'LBL_DELETE_RECORD_COMPLETELY',
                      'linkurl' => 'javascript:Calendar_Detail_Js.deleteRecord("index.php?module=' . $recordModel->getModuleName() . '&action=Delete&record=' . $recordModel->getId() . '")',
                      'linkicon' => 'fas fa-eraser',

      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' => 'LBL_SHOW_LOCATION',
                      'linkurl' => 'javascript:Vtiger_Index_Js.showLocation(this)',
                      'linkdata' => ['location' => $recordModel->getDisplayValue('location')],

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

              if (!$recordModel->isReadOnly() && !$recordModel->isEmpty('location') && App\Privilege::isPermitted('OpenStreetMap')) {

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

                      if ('LBL_MOVE_TO_TRASH' == $linkObject->linklabel) {

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

                  foreach ($linkModelList['DETAIL_VIEW_EXTENDED'] as $key => $linkObject) {

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

                      if ('LBL_DELETE_RECORD_COMPLETELY' == $linkObject->linklabel) {

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

                      'linklabel' => 'LBL_SET_RECORD_STATUS',

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "linkclass" 5 times.
      Open

                      'linkclass' => 'btn-outline-dark btn-sm showModal closeCalendarRekord',

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

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

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

                      'linkdata' => ['url' => $recordModel->getActivityStateModalUrl()],

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

                      'linkurl' => '#',

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

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

      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" 5 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.

      Class extends undeclared class \Vtiger_DetailView_Model
      Open

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

      Reference to undeclared class \Vtiger_DetailView_Model
      Open

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

      Call to undeclared method \Calendar_DetailView_Model::getModule
      Open

              if ($recordModel->isEditable() && $this->getModule()->isPermitted('DetailView') && \App\Privilege::isPermitted($moduleName, 'ActivityComplete', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityCancel', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityPostponed', $recordId) && \in_array($recordModel->get('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {
      Severity: Critical
      Found in modules/Calendar/models/DetailView.php by phan

      Call to undeclared method \Calendar_DetailView_Model::getRecord
      Open

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

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

      class Calendar_DetailView_Model extends Vtiger_DetailView_Model

      The class Calendar_DetailView_Model is not named in CamelCase.
      Open

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

                  foreach ($linkModelList['DETAIL_VIEW_EXTENDED'] as $key => $linkObject) {

      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

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

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

                      'linkurl' => 'javascript:Vtiger_Index_Js.showLocation(this)',

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

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

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

              }

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

                      }

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

                      'linklabel' => 'LBL_DELETE_RECORD_COMPLETELY',

      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

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

      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

                      'linkurl' => '#',

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

                      'linkclass' => 'btn-outline-dark btn-sm showModal closeCalendarRekord',

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

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

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

                  ]);

      Line exceeds 120 characters; contains 194 characters
      Open

                      'linkurl' => 'javascript:Calendar_Detail_Js.deleteRecord("index.php?module=' . $recordModel->getModuleName() . '&action=State&state=Trash&record=' . $recordModel->getId() . '")',

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

                      'linktype' => 'DETAIL_VIEW_EXTENDED',

      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

                      }

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

                      'linktype' => 'DETAIL_VIEW_EXTENDED',

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

                          unset($linkModelList['DETAIL_VIEW_EXTENDED'][$key]);

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

                      'title' => \App\Language::translate('LBL_DELETE_RECORD_COMPLETELY'),

      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 (!$recordModel->isReadOnly() && !$recordModel->isEmpty('location') && App\Privilege::isPermitted('OpenStreetMap')) {

      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

              if (!$recordModel->isReadOnly() && $recordModel->privilegeToMoveToTrash() && 1 === $recordModel->get('reapeat')) {

      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

                  $stateColors = App\Config::search('LIST_ENTITY_STATE_COLOR');

      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

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

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

                      'linklabel' => 'LBL_SEND_CALENDAR',

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

                      'linkdata' => ['url' => "index.php?module={$moduleName}&view=SendInvitationModal&record={$recordId}"],

      Line exceeds 120 characters; contains 127 characters
      Open

              if (!$recordModel->isReadOnly() && !$recordModel->isEmpty('location') && App\Privilege::isPermitted('OpenStreetMap')) {

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

                  foreach ($linkModelList['DETAIL_VIEW_EXTENDED'] as $key => $linkObject) {

      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

                      'linkdata' => ['url' => $recordModel->getActivityStateModalUrl()],

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

                      'linkdata' => ['location' => $recordModel->getDisplayValue('location')],

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

                      'title' => \App\Language::translate('LBL_MOVE_TO_TRASH'),

      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

          public function getDetailViewLinks(array $linkParams): array

      Line exceeds 120 characters; contains 430 characters
      Open

              if ($recordModel->isEditable() && $this->getModule()->isPermitted('DetailView') && \App\Privilege::isPermitted($moduleName, 'ActivityComplete', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityCancel', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityPostponed', $recordId) && \in_array($recordModel->get('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {

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

                          unset($linkModelList['DETAIL_VIEW_EXTENDED'][$key]);

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

                      'linklabel' => 'LBL_MOVE_TO_TRASH',

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

                      'linkurl' => 'javascript:Calendar_Detail_Js.deleteRecord("index.php?module=' . $recordModel->getModuleName() . '&action=Delete&record=' . $recordModel->getId() . '")',

      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

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

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

              }

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

                      'style' => empty($stateColors['Trash']) ? '' : "background: {$stateColors['Trash']};",

      Line exceeds 120 characters; contains 183 characters
      Open

                      'linkurl' => 'javascript:Calendar_Detail_Js.deleteRecord("index.php?module=' . $recordModel->getModuleName() . '&action=Delete&record=' . $recordModel->getId() . '")',

      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

              }

      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 (!$recordModel->isReadOnly() && $recordModel->privilegeToDelete() && 1 === $recordModel->get('reapeat')) {

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

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

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

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

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

      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

                      'linklabel' => 'LBL_SET_RECORD_STATUS',

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

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

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

                      'linkicon' => 'fas fa-map-marker-alt',

      Line exceeds 120 characters; contains 122 characters
      Open

              if (!$recordModel->isReadOnly() && $recordModel->privilegeToMoveToTrash() && 1 === $recordModel->get('reapeat')) {

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

                      if ('LBL_MOVE_TO_TRASH' == $linkObject->linklabel) {

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

                      'linkurl' => 'javascript:Calendar_Detail_Js.deleteRecord("index.php?module=' . $recordModel->getModuleName() . '&action=State&state=Trash&record=' . $recordModel->getId() . '")',

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

                      'linkicon' => 'fas fa-trash-alt',

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

              if ($recordModel->isEditable() && $this->getModule()->isPermitted('DetailView') && \App\Privilege::isPermitted($moduleName, 'ActivityComplete', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityCancel', $recordId) && \App\Privilege::isPermitted($moduleName, 'ActivityPostponed', $recordId) && \in_array($recordModel->get('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {

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

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

                      if ('LBL_DELETE_RECORD_COMPLETELY' == $linkObject->linklabel) {

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

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

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

      class Calendar_DetailView_Model extends Vtiger_DetailView_Model

      There are no issues that match your filters.

      Category
      Status