YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/actions/Widget.php

Summary

Maintainability
C
1 day
Test Coverage
F
0%

Consider simplifying this complex logical expression.
Open

        if (('updateWidgetConfig' === $mode && $request->has('widgetid') && $widget->get('active'))
            || (('remove' === $mode || 'removeWidgetFromList' === $mode) && !$widget->isDefault() && \App\Privilege::isPermitted($moduleName))
            || (('positions' === $mode || 'clear' === $mode) && \App\Privilege::isPermitted($moduleName))
            || 'add' === $mode) {
            return true;
Severity: Critical
Found in modules/Vtiger/actions/Widget.php - About 2 hrs to fix

    Function positions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public function positions(App\Request $request): void
        {
            $currentUserId = App\User::getCurrentUserId();
            if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer',    'col' => 'Integer']])) {
                foreach ($positionsMap as $id => $position) {
    Severity: Minor
    Found in modules/Vtiger/actions/Widget.php - About 1 hr 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

    Method add has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function add(App\Request $request)
        {
            $moduleName = $request->getByType('sourceModule', \App\Purifier::ALNUM);
            $data = $request->getMultiDimensionArray('form', [
                'data' => 'Text',
    Severity: Minor
    Found in modules/Vtiger/actions/Widget.php - About 1 hr to fix

      Function checkPermission has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function checkPermission(App\Request $request)
          {
              $moduleName = $request->getModule();
              $mode = $request->getMode();
              if ($request->has('widgetid')) {
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php - About 55 mins 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

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

          public function checkPermission(App\Request $request)
          {
              $moduleName = $request->getModule();
              $mode = $request->getMode();
              if ($request->has('widgetid')) {
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      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

      Missing class import via use statement (line '55', column '13').
      Open

              throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '128', column '19').
      Open

              $response = new Vtiger_Response();
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '141', column '19').
      Open

              $response = new Vtiger_Response();
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '125', column '34').
      Open

                  $widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '163', column '19').
      Open

              $response = new Vtiger_Response();
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '66', column '19').
      Open

              $response = new Vtiger_Response();
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '122', column '14').
      Open

                  throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '199', column '19').
      Open

              $response = new Vtiger_Response();
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'removeWidgetFromList'.
      Open

              Vtiger_Widget_Model::removeWidgetFromList($request->getInteger('widgetid'));
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid assigning values to variables in if clauses and the like (line '188', column '7').
      Open

          public function positions(App\Request $request): void
          {
              $currentUserId = App\User::getCurrentUserId();
              if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer',    'col' => 'Integer']])) {
                  foreach ($positionsMap as $id => $position) {
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      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 'App\User' in method 'positions'.
      Open

              $currentUserId = App\User::getCurrentUserId();
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'checkPermission'.
      Open

                  $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'remove'.
      Open

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'remove'.
      Open

                  $widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class '\App\User' in method 'remove'.
      Open

                  $widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      The method add uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $data['linkid'] = $request->getInteger('linkid');
                  $widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();
                  $result = $widgetsManagementModel->addWidget($data, $moduleName, $request->getBoolean('addToUser'));
              }
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

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

      Avoid using static access to class '\App\User' in method 'remove'.
      Open

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'updateWidgetConfig'.
      Open

              $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, \App\User::getCurrentUserId());
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  || (('positions' === $mode || 'clear' === $mode) && \App\Privilege::isPermitted($moduleName))
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      The method remove uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
              }
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

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

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

                  'title' => \App\Language::translate($widget->getTitle(), $request->getModule()),
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class '\App\User' in method 'updateWidgetConfig'.
      Open

              $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, \App\User::getCurrentUserId());
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'checkPermission'.
      Open

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'clear'.
      Open

              Vtiger_Widget_Model::clearDeviceConf(Vtiger_Widget_Model::getDashboardId($request));
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  || (('remove' === $mode || 'removeWidgetFromList' === $mode) && !$widget->isDefault() && \App\Privilege::isPermitted($moduleName))
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'positions'.
      Open

                          Vtiger_Widget_Model::updateWidgetSize($size, null, (int) $widgetId, $currentUserId);
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'clear'.
      Open

              Vtiger_Widget_Model::clearDeviceConf(Vtiger_Widget_Model::getDashboardId($request));
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class '\App\User' in method 'checkPermission'.
      Open

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'App\User' in method 'updateWidgetConfig'.
      Open

              ['userid' => App\User::getCurrentUserId(), 'id' => $widgetId])
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      The method positions uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          Vtiger_Widget_Model::updateWidgetSize($size, (int) $linkId, null, $currentUserId);
                      }
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'positions'.
      Open

                          Vtiger_Widget_Model::updateWidgetPosition($position, null, (int) $widgetId, $currentUserId);
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  $result = ['success' => false, 'message' => \App\Language::translate('LBL_INVALID_DATA', $moduleName)];
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class '\vtlib\Link' in method 'add'.
      Open

              } elseif (!Vtiger_Widget_Model::getInstanceFromValues(array_merge($data, \vtlib\Link::getLinkData($request->getInteger('linkid'))))->isCreatable()) {
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Loader' in method 'updateWidgetConfig'.
      Open

              $className = Vtiger_Loader::getComponentClassName('Dashboard', $widget->get('linklabel'), $moduleName);
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid assigning values to variables in if clauses and the like (line '178', column '7').
      Open

          public function positions(App\Request $request): void
          {
              $currentUserId = App\User::getCurrentUserId();
              if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer',    'col' => 'Integer']])) {
                  foreach ($positionsMap as $id => $position) {
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      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 '\App\User' in method 'checkPermission'.
      Open

                  $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      The method positions uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          Vtiger_Widget_Model::updateWidgetPosition($position, (int) $linkId, null, $currentUserId);
                      }
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'positions'.
      Open

                          Vtiger_Widget_Model::updateWidgetPosition($position, (int) $linkId, null, $currentUserId);
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Widget_Model' in method 'positions'.
      Open

                          Vtiger_Widget_Model::updateWidgetSize($size, (int) $linkId, null, $currentUserId);
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Define a constant instead of duplicating this literal "Standard" 6 times.
      Open

                      'Standard',
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by sonar-php

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Define a constant instead of duplicating this literal "Integer" 14 times.
      Open

                  'blockid' => 'Integer',
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by sonar-php

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Define a constant instead of duplicating this literal "widgetid" 7 times.
      Open

              if ($request->has('widgetid')) {
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by sonar-php

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Define a constant instead of duplicating this literal "linkid" 7 times.
      Open

                  $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by sonar-php

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

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

                  $widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method removeWidgetFromList from undeclared class \Vtiger_Widget_Model
      Open

              Vtiger_Widget_Model::removeWidgetFromList($request->getInteger('widgetid'));
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method getInstanceWithWidgetId from undeclared class \Vtiger_Widget_Model
      Open

              $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method getInstance from undeclared class \Vtiger_Widget_Model
      Open

                  $widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method getInstanceFromValues from undeclared class \Vtiger_Widget_Model
      Open

              } elseif (!Vtiger_Widget_Model::getInstanceFromValues(array_merge($data, \vtlib\Link::getLinkData($request->getInteger('linkid'))))->isCreatable()) {
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method getInstanceWithWidgetId from undeclared class \Vtiger_Widget_Model
      Open

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

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

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method getInstanceWithWidgetId from undeclared class \Vtiger_Widget_Model
      Open

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

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

                  $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method get on non-class type null
      Open

              if (('updateWidgetConfig' === $mode && $request->has('widgetid') && $widget->get('active'))
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method getDashboardId from undeclared class \Vtiger_Widget_Model
      Open

              Vtiger_Widget_Model::clearDeviceConf(Vtiger_Widget_Model::getDashboardId($request));
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method updateWidgetPosition from undeclared class \Vtiger_Widget_Model
      Open

                          Vtiger_Widget_Model::updateWidgetPosition($position, null, (int) $widgetId, $currentUserId);
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

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

              $currentUserId = App\User::getCurrentUserId();
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method updateWidgetSize from undeclared class \Vtiger_Widget_Model
      Open

                          Vtiger_Widget_Model::updateWidgetSize($size, null, (int) $widgetId, $currentUserId);
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method updateWidgetSize from undeclared class \Vtiger_Widget_Model
      Open

                          Vtiger_Widget_Model::updateWidgetSize($size, (int) $linkId, null, $currentUserId);
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method updateWidgetPosition from undeclared class \Vtiger_Widget_Model
      Open

                          Vtiger_Widget_Model::updateWidgetPosition($position, (int) $linkId, null, $currentUserId);
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to undeclared method \App\Db::createCommand
      Open

              $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => $widget->get('data')],
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method getInstance from undeclared class \Vtiger_Widget_Model
      Open

                  $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method isDefault on non-class type null
      Open

                  || (('remove' === $mode || 'removeWidgetFromList' === $mode) && !$widget->isDefault() && \App\Privilege::isPermitted($moduleName))
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

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

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

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

              $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, \App\User::getCurrentUserId());
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

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

              ['userid' => App\User::getCurrentUserId(), 'id' => $widgetId])
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

      Call to method clearDeviceConf from undeclared class \Vtiger_Widget_Model
      Open

              Vtiger_Widget_Model::clearDeviceConf(Vtiger_Widget_Model::getDashboardId($request));
      Severity: Critical
      Found in modules/Vtiger/actions/Widget.php by phan

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

              if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer',    'col' => 'Integer']])) {
                  foreach ($positionsMap as $id => $position) {
                      [$linkId, $widgetId] = array_pad(explode('-', $id), 2, false);
                      if ($widgetId) {
                          Vtiger_Widget_Model::updateWidgetPosition($position, null, (int) $widgetId, $currentUserId);
      Severity: Major
      Found in modules/Vtiger/actions/Widget.php and 1 other location - About 2 hrs to fix
      modules/Vtiger/actions/Widget.php on lines 188..197

      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 137.

      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

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

              if ($sizesMap = $request->getMultiDimensionArray('size', [['width' => 'Integer', 'height' => 'Integer']])) {
                  foreach ($sizesMap as $id => $size) {
                      [$linkId, $widgetId] = array_pad(explode('-', $id), 2, false);
                      if ($widgetId) {
                          Vtiger_Widget_Model::updateWidgetSize($size, null, (int) $widgetId, $currentUserId);
      Severity: Major
      Found in modules/Vtiger/actions/Widget.php and 1 other location - About 2 hrs to fix
      modules/Vtiger/actions/Widget.php on lines 178..187

      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 137.

      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

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

                  $widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      LongVariable

      Since: 0.2

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

      Example

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

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

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

      class Vtiger_Widget_Action extends \App\Controller\Action

      The class Vtiger_Widget_Action is not named in CamelCase.
      Open

      class Vtiger_Widget_Action extends \App\Controller\Action
      {
          use \App\Controller\ExposeMethod;
      
          /**
      Severity: Minor
      Found in modules/Vtiger/actions/Widget.php by phpmd

      CamelCaseClassName

      Since: 0.2

      It is considered best practice to use the CamelCase notation to name classes.

      Example

      class class_name {
      }

      Source

      Spaces must be used for alignment; tabs are not allowed
      Open

                  }

      Spaces must be used for alignment; tabs are not allowed
      Open

          /**

      Spaces must be used for alignment; tabs are not allowed
      Open

                      } else {

      Spaces must be used for alignment; tabs are not allowed
      Open

                      if ($widgetId) {

      Spaces must be used for alignment; tabs are not allowed
      Open

           * @return void

      Spaces must be used for alignment; tabs are not allowed
      Open

                          Vtiger_Widget_Model::updateWidgetSize($size, (int) $linkId, null, $currentUserId);

      Spaces must be used for alignment; tabs are not allowed
      Open

                      [$linkId, $widgetId] = array_pad(explode('-', $id), 2, false);

      Spaces must be used for alignment; tabs are not allowed
      Open

                          Vtiger_Widget_Model::updateWidgetSize($size, null, (int) $widgetId, $currentUserId);

      Spaces must be used for alignment; tabs are not allowed
      Open

                      }

      Spaces must be used for alignment; tabs are not allowed
      Open

                  foreach ($sizesMap as $id => $size) {

      Spaces must be used for alignment; tabs are not allowed
      Open

           * Clear configuration of widgets for this device.

      Spaces must be used for alignment; tabs are not allowed
      Open

              Vtiger_Widget_Model::clearDeviceConf(Vtiger_Widget_Model::getDashboardId($request));

      Spaces must be used for alignment; tabs are not allowed
      Open

           * @param App\Request $request

      Spaces must be used for alignment; tabs are not allowed
      Open

                  foreach ($positionsMap as $id => $position) {

      Spaces must be used for alignment; tabs are not allowed
      Open

                      [$linkId, $widgetId] = array_pad(explode('-', $id), 2, false);

      Spaces must be used for alignment; tabs are not allowed
      Open

                      }

      Spaces must be used for alignment; tabs are not allowed
      Open

              $response->emit();

      Spaces must be used for alignment; tabs are not allowed
      Open

                      } else {

      Spaces must be used for alignment; tabs are not allowed
      Open

                  }

      Spaces must be used for alignment; tabs are not allowed
      Open

           */

      Spaces must be used for alignment; tabs are not allowed
      Open

              if ($sizesMap = $request->getMultiDimensionArray('size', [['width' => 'Integer', 'height' => 'Integer']])) {

      Spaces must be used for alignment; tabs are not allowed
      Open

              }

      Spaces must be used for alignment; tabs are not allowed
      Open

                      if ($widgetId) {

      Spaces must be used for alignment; tabs are not allowed
      Open

              }

      Spaces must be used for alignment; tabs are not allowed
      Open

           *

      Spaces must be used for alignment; tabs are not allowed
      Open

                          Vtiger_Widget_Model::updateWidgetPosition($position, null, (int) $widgetId, $currentUserId);

      Spaces must be used for alignment; tabs are not allowed
      Open

              header("location: index.php?module={$request->getModule()}&view=DashBoard");

      Spaces must be used for alignment; tabs are not allowed
      Open

          }

      Spaces must be used for alignment; tabs are not allowed
      Open

              if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer',    'col' => 'Integer']])) {

      Spaces must be used for alignment; tabs are not allowed
      Open

           *

      Spaces must be used for alignment; tabs are not allowed
      Open

          public function clear(App\Request $request): void

      Spaces must be used for alignment; tabs are not allowed
      Open

          {

      Spaces must be used for alignment; tabs are not allowed
      Open

                          Vtiger_Widget_Model::updateWidgetPosition($position, (int) $linkId, null, $currentUserId);

      Spaces must be used for alignment; tabs are not allowed
      Open

          }

      Spaces must be used for alignment; tabs are not allowed
      Open

              $response = new Vtiger_Response();

      Spaces must be used for alignment; tabs are not allowed
      Open

              $response->setResult(true);

      Only one argument is allowed per line in a multi-line function call
      Open

              $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => $widget->get('data')],

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

          /**

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

                  || (('remove' === $mode || 'removeWidgetFromList' === $mode) && !$widget->isDefault() && \App\Privilege::isPermitted($moduleName))

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

          }

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

              $linkId = $request->getInteger('linkid');

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

                  || (('positions' === $mode || 'clear' === $mode) && \App\Privilege::isPermitted($moduleName))

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

          /**

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

          public function remove(App\Request $request)

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

           * @throws \App\Exceptions\NoPermitted

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

              $moduleName = $request->getModule();

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

           *

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

           * Constructor.

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

          public function __construct()

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

              $this->exposeMethod('removeWidgetFromList');

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

          public function checkPermission(App\Request $request)

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

          {

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

              if (('updateWidgetConfig' === $mode && $request->has('widgetid') && $widget->get('active'))

      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 true;

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

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

           * @param \App\Request $request

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

              if ($request->has('widgetid')) {

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

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());

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

              }

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

           * Remove widget.

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

              $this->exposeMethod('add');

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

              $this->exposeMethod('updateWidgetConfig');

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

           */

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

              $mode = $request->getMode();

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

              } elseif ('add' !== $mode) {

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

           * @param \App\Request $request

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

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());

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

              $response->emit();

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

                  'skip_year' => 'Integer',

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

                  'date_fields' => 'Integer',

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

                  $result = ['success' => false, 'message' => \App\Language::translate('LBL_INVALID_DATA', $moduleName)];

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

              } elseif (!Vtiger_Widget_Model::getInstanceFromValues(array_merge($data, \vtlib\Link::getLinkData($request->getInteger('linkid'))))->isCreatable()) {

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

                  $data['linkid'] = $request->getInteger('linkid');

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

           * @param App\Request $request

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

          use \App\Controller\ExposeMethod;

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

          /**

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

              parent::__construct();

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

                  || 'add' === $mode) {

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

              $widget->remove('hide');

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

                  'url' => $widget->getUrl(),

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

           * Function to add widget.

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

                  'filterid' => 'Text',

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

                      'Standard',

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

                  'limit' => 'Integer',

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

              $response = new Vtiger_Response();

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

           *

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

                  'owners_all' => [

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

           */

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

           * Function to check permission.

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

                  'default_owner' => 'Standard',

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

           * @param \App\Request $request

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

           * Save updates widget config.

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

          public function updateWidgetConfig(App\Request $request)

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

              $this->exposeMethod('clear');

      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

                  'title' => 'Text',

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

                  'width' => 'Integer',

      Line exceeds 120 characters; contains 157 characters
      Open

              } elseif (!Vtiger_Widget_Model::getInstanceFromValues(array_merge($data, \vtlib\Link::getLinkData($request->getInteger('linkid'))))->isCreatable()) {

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

           * Remove widget from list.

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

           * @param \App\Request $request

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

          public function positions(App\Request $request): void

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

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

          }

      Line exceeds 120 characters; contains 132 characters
      Open

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());

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

              throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');

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

          public function add(App\Request $request)

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

                  'data' => 'Text',

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

              ]);

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

              $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, \App\User::getCurrentUserId());

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

              $data = $request->getArray('widgetData', \App\Purifier::TEXT);

      Line exceeds 120 characters; contains 141 characters
      Open

              $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => $widget->get('data')],

      Line exceeds 120 characters; contains 132 characters
      Open

                  $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($request->getInteger('widgetid'), \App\User::getCurrentUserId());

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

                  'title' => \App\Language::translate($widget->getTitle(), $request->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

          {

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

                  'label' => 'Text',

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

              if (!\is_array($data) || !$data) {

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

              Vtiger_Widget_Model::removeWidgetFromList($request->getInteger('widgetid'));

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

          /**

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

              $response->setResult($result);

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

          /**

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

                  $widget = Vtiger_Widget_Model::getInstance($linkId, \App\User::getCurrentUserId());

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

          }

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

                  'dashboardId' => 'Integer',

      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

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

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

                      'Standard',

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

                  'sortOrder' => 'Text',

      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 removeWidgetFromList(App\Request $request)

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

              $response->emit();

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

                  'blockid' => 'Integer',

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

                  'linkid' => 'Integer',

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

              } else {

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

                  $result = $widgetsManagementModel->addWidget($data, $moduleName, $request->getBoolean('addToUser'));

      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

              if ($positionsMap = $request->getMultiDimensionArray('position', [['row' => 'Integer',    'col' => 'Integer']])) {

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

           *

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

                  $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), \App\User::getCurrentUserId());

      Line exceeds 120 characters; contains 142 characters
      Open

                  || (('remove' === $mode || 'removeWidgetFromList' === $mode) && !$widget->isDefault() && \App\Privilege::isPermitted($moduleName))

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

          {

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

              } else {

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

                  ],

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

                  'default_date' => 'Standard',

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

              $response->setResult($result);

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

              $response->setResult(true);

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

              $response = new Vtiger_Response();

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

          {

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

                  'name' => $widget->getName(),

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

           * @param \App\Request $request

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

              $data = $request->getMultiDimensionArray('form', [

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

                  'isdefault' => 'Integer',

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

                      'Standard',

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

                  'cache' => 'Integer',

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

                  $widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();

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

                  ->execute();

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

           * @return void

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

              $currentUserId = App\User::getCurrentUserId();

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

                  'name' => 'Text',

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

                  throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');

      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

              $widgetId = $request->getInteger('widgetid');

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

              $className = Vtiger_Loader::getComponentClassName('Dashboard', $widget->get('linklabel'), $moduleName);

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

              $instance = new $className();

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

           *

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

              $response = new Vtiger_Response();

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

              if ($request->has('widgetid')) {

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

          /**

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

                  'height' => 'Integer',

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

                      'Standard',

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

          /**

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

                  'deleteFromList' => $widget->isDeletable(),

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

              $response->emit();

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

              $response->emit();

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

              $moduleName = $request->getModule();

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

              $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => $widget->get('data')],

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

              ['userid' => App\User::getCurrentUserId(), 'id' => $widgetId])

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

           * Save positions.

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

              }

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

              $response->setResult(['linkid' => $linkId,

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

                  'id' => $widget->get('id'),

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

              }

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

              $response = new Vtiger_Response();

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

           */

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

              $instance->setWidgetData($widget, $data);

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

      class Vtiger_Widget_Action extends \App\Controller\Action

      Closing parenthesis of a multi-line function call must be on a line by itself
      Open

              ['userid' => App\User::getCurrentUserId(), 'id' => $widgetId])

      Opening parenthesis of a multi-line function call must be the last content on the line
      Open

              $result = (bool) \App\Db::getInstance()->createCommand()->update('vtiger_module_dashboard_widgets', ['data' => $widget->get('data')],

      There are no issues that match your filters.

      Category
      Status