YetiForceCompany/YetiForceCRM

View on GitHub
modules/OSSTimeControl/dashboards/TimeControl.php

Summary

Maintainability
C
1 day
Test Coverage
F
0%

Function getWidgetTimeControl has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public function getWidgetTimeControl($user, $date)
    {
        if (!$date) {
            return ['show_chart' => false];
        }
Severity: Minor
Found in modules/OSSTimeControl/dashboards/TimeControl.php - About 5 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

Method getWidgetTimeControl has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getWidgetTimeControl($user, $date)
    {
        if (!$date) {
            return ['show_chart' => false];
        }
Severity: Major
Found in modules/OSSTimeControl/dashboards/TimeControl.php - About 3 hrs to fix

    Method process has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function process(App\Request $request)
        {
            $currentUserId = \App\User::getCurrentUserId();
            $viewer = $this->getViewer($request);
            $moduleName = $request->getModule();
    Severity: Minor
    Found in modules/OSSTimeControl/dashboards/TimeControl.php - About 1 hr to fix

      Function process has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function process(App\Request $request)
          {
              $currentUserId = \App\User::getCurrentUserId();
              $viewer = $this->getViewer($request);
              $moduleName = $request->getModule();
      Severity: Minor
      Found in modules/OSSTimeControl/dashboards/TimeControl.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

      The method getWidgetTimeControl() has an NPath complexity of 816. The configured NPath complexity threshold is 200.
      Open

          public function getWidgetTimeControl($user, $date)
          {
              if (!$date) {
                  return ['show_chart' => false];
              }

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

          public function getWidgetTimeControl($user, $date)
          {
              if (!$date) {
                  return ['show_chart' => false];
              }

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

          public function getWidgetTimeControl($user, $date)

      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

      Missing class import via use statement (line '40', column '17').
      Open

              $query = (new App\Db\Query())->select(['sum_time', 'due_date', 'vtiger_osstimecontrol.timecontrol_type', 'timecontrol_typeid'])

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

              $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUserId);

      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\Fields\Date' in method 'getSearchParams'.
      Open

              $date = \App\Fields\Date::formatToDisplay($date);

      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 getWidgetTimeControl uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                  } else {
                      $workingTime[$row['due_date']][$row['timecontrol_type']] = (float) $row['sum_time'];
                  }

      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

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

                  } else {
                      $workingTimeByType[$label] = (float) $row['sum_time'];
                  }

      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

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

                          } else {
                              $value = 0;
                          }

      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 'Settings_WidgetsManagement_Module_Model' in method 'process'.
      Open

                  $time = Settings_WidgetsManagement_Module_Model::getDefaultDateRange($widget);

      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\Fields\Picklist' in method 'getWidgetTimeControl'.
      Open

              $colors = \App\Fields\Picklist::getColors('timecontrol_type');

      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 'Settings_TimeControlProcesses_Module_Model' in method 'process'.
      Open

              $TCPModuleModel = Settings_TimeControlProcesses_Module_Model::getCleanInstance();

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

                  $label = \App\Language::translate($row['timecontrol_type'], 'OSSTimeControl');

      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\Fields\RangeTime' in method 'getWidgetTimeControl'.
      Open

                  $dataset['label'] .= ': ' . \App\Fields\RangeTime::displayElapseTime($workingTimeByType[$dataset['label']]);

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

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

      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\PrivilegeQuery' in method 'getWidgetTimeControl'.
      Open

              \App\PrivilegeQuery::getConditions($query, 'OSSTimeControl');

      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\Fields\Date' in method 'process'.
      Open

              $viewer->assign('DTIME', \App\Fields\Date::formatRangeToDisplay($time));

      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 process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $viewer->view('dashboards/TimeControl.tpl', $moduleName);
              }

      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\Fields\DateTime' in method 'getWidgetTimeControl'.
      Open

                      $chartData['fullLabels'][] = \App\Fields\DateTime::formatToDay($row['due_date'], true);

      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\Fields\RangeTime' in method 'getWidgetTimeControl'.
      Open

                                  $dataset['dataFormatted'][] = \App\Fields\RangeTime::displayElapseTime($value);

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

                  return ['show_chart' => false];

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

                  'datasets' => [],

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

                          'label' => $label,

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

              $colors = \App\Fields\Picklist::getColors('timecontrol_type');

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

                  ->where(['vtiger_crmentity.setype' => 'OSSTimeControl', 'vtiger_crmentity.smownerid' => $user]);

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

                  array_push($conditions, ['due_date', 'bw', $date . ',' . $date]);

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

              $query = (new App\Db\Query())->select(['sum_time', 'due_date', 'vtiger_osstimecontrol.timecontrol_type', 'timecontrol_typeid'])

      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.

      Avoid unused local variables such as '$dataItem'.
      Open

                      foreach ($dataset['data'] as $index => $dataItem) {

      UnusedLocalVariable

      Since: 0.2

      Detects when a local variable is declared and/or assigned, but not used.

      Example

      class Foo {
          public function doSomething()
          {
              $i = 5; // Unused
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

      Call to method getInstance from undeclared class \Vtiger_Widget_Model
      Open

              $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUserId);

      Call to undeclared method \Vtiger_Viewer::assign
      Open

              $viewer->assign('USERID', $user);

      Call to undeclared method \Vtiger_Viewer::assign
      Open

              $viewer->assign('DTIME', \App\Fields\Date::formatRangeToDisplay($time));

      Call to undeclared method \Vtiger_Viewer::assign
      Open

              $viewer->assign('DATA', $data);

      Call to undeclared method \Vtiger_Viewer::assign
      Open

              $viewer->assign('TCPMODULE_MODEL', $TCPModuleModel->getConfigInstance());

      Call to undeclared method \Vtiger_Viewer::assign
      Open

              $viewer->assign('LOGGEDUSERID', $currentUserId);

      Saw an @param annotation for owner, but it was not found in the param list of function getSearchParams(mixed $assignedto, string $date) : string
      Open

           * @param int|string $owner

      Call to undeclared method \Vtiger_Viewer::assign
      Open

              $viewer->assign('SOURCE_MODULE', 'OSSTimeControl');

      Call to undeclared method \Vtiger_Viewer::assign
      Open

              $viewer->assign('MODULE_NAME', $moduleName);

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

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

      Call to undeclared method \Vtiger_Viewer::assign
      Open

              $viewer->assign('WIDGET', $widget);

      Call to undeclared method \App\Db\Query::select
      Open

              $query = (new App\Db\Query())->select(['sum_time', 'due_date', 'vtiger_osstimecontrol.timecontrol_type', 'timecontrol_typeid'])

      Call to undeclared method \Vtiger_Viewer::assign
      Open

              $viewer->assign('USER_CONDITIONS', null);

      Expected @param annotation for assignedto to be before the @param annotation for date
      Open

           * @param string     $date

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

                  if (!\in_array($row['timecontrol_type'], $timeTypes)) {
                      $timeTypes[$row['timecontrol_typeid']] = $row['timecontrol_type'];
                      // one dataset per type
                      $chartData['datasets'][] = [
                          'label' => $label,
      Severity: Minor
      Found in modules/OSSTimeControl/dashboards/TimeControl.php and 1 other location - About 50 mins to fix
      modules/OSSTimeControl/dashboards/AllTimeControl.php on lines 76..88

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

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

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

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

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

      Refactorings

      Further Reading

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

      class OSSTimeControl_TimeControl_Dashboard extends Vtiger_IndexAjax_View

      The class OSSTimeControl_TimeControl_Dashboard is not named in CamelCase.
      Open

      class OSSTimeControl_TimeControl_Dashboard extends Vtiger_IndexAjax_View
      {
          /**
           * Return search params (use to in building address URL to listview).
           *

      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

                  array_push($conditions, ['assigned_user_id', 'e', $assignedto]);

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

              if (!empty($date)) {

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

                  'datasets' => [],

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

           * Return search params (use to in building address URL to listview).

      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

                  ['<=', 'vtiger_osstimecontrol.due_date', $date[1]],

      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 ('' != $assignedto) {

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

          }

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

              $chartData = [

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

          public function getSearchParams($assignedto, $date)

      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

                  array_push($conditions, ['due_date', 'bw', $date . ',' . $date]);

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

              if (!$date) {

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

                  'show_chart' => false,

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

                  'fullLabels' => [],

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

                      $workingTime[$row['due_date']][$row['timecontrol_type']] += (float) $row['sum_time'];

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

                          'original_label' => $label,

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

                          'backgroundColor' => [],

      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 ($dataReader->count() > 0) {

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

                                  $dataset['data'][] = round($value / 60, 2);

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

                                  $dataset['dataFormatted'][] = \App\Fields\RangeTime::displayElapseTime($value);

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

              $dataReader->close();

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

              $viewer->assign('WIDGET', $widget);

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

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

      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

                  ['vtiger_osstimecontrol.deleted' => 0],

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

              $colors = \App\Fields\Picklist::getColors('timecontrol_type');

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

                      $workingTimeByType[$label] += (float) $row['sum_time'];

      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'), $currentUserId);

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

              $viewer->assign('USER_CONDITIONS', null);

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

           * @param string     $date

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

              $date = \App\Fields\Date::formatToDisplay($date);

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

              $listSearchParams = [];

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

                  ->where(['vtiger_crmentity.setype' => 'OSSTimeControl', 'vtiger_crmentity.smownerid' => $user]);

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

              \App\PrivilegeQuery::getConditions($query, 'OSSTimeControl');

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

                  'and',

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

                  $chartData['show_chart'] = true;

      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

                  $time = Settings_WidgetsManagement_Module_Model::getDefaultDateRange($widget);

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

              $data = $this->getWidgetTimeControl($user, $time);

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

                      }

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

              $viewer->assign('USERID', $user);

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

                  $viewer->view('dashboards/TimeControl.tpl', $moduleName);

      Line exceeds 120 characters; contains 135 characters
      Open

                  ->innerJoin('vtiger_timecontrol_type', 'vtiger_osstimecontrol.timecontrol_type = vtiger_timecontrol_type.timecontrol_type')

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

              while ($row = $dataReader->read()) {

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

                      $workingTime[$row['due_date']][$row['timecontrol_type']] = (float) $row['sum_time'];

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

                          'links' => [],

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

                      $chartData['fullLabels'][] = \App\Fields\DateTime::formatToDay($row['due_date'], true);

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

                  foreach ($data['datasets'] as &$dataset) {

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

              $viewer->assign('MODULE_NAME', $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 getWidgetTimeControl($user, $date)

      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

                          foreach ($chartData['datasets'] as &$dataset) {

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

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

              $viewer = $this->getViewer($request);

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

              $viewer->assign('LOGGEDUSERID', $currentUserId);

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

                  ->innerJoin('vtiger_crmentity', 'vtiger_osstimecontrol.osstimecontrolid = vtiger_crmentity.crmid')

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

              $query->andWhere([

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

              $timeTypes = [];

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

                  if (isset($workingTimeByType[$label])) {

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

                      $chartData['datasets'][] = [

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

                      $chartData['labels'][] = substr($row['due_date'], -2);

      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 (empty($time)) {

      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

              $conditions = [];

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

                  return ['show_chart' => false];

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

                  'days' => []

      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 (isset($workingTime[$row['due_date']][$row['timecontrol_type']])) {

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

                      $chartData['days'][] = $row['due_date'];

      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

                      foreach ($dataset['data'] as $index => $dataItem) {

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

              $viewer->assign('DATA', $data);

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

                  ->innerJoin('vtiger_timecontrol_type', 'vtiger_osstimecontrol.timecontrol_type = vtiger_timecontrol_type.timecontrol_type')

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

              $workingTimeByType = $workingTime = [];

      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 (!\in_array($row['due_date'], $chartData['days'])) {

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

                  $dataset['label'] .= ': ' . \App\Fields\RangeTime::displayElapseTime($workingTimeByType[$dataset['label']]);

      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

              $query = (new App\Db\Query())->select(['sum_time', 'due_date', 'vtiger_osstimecontrol.timecontrol_type', 'timecontrol_typeid'])

      Line exceeds 120 characters; contains 135 characters
      Open

              $query = (new App\Db\Query())->select(['sum_time', 'due_date', 'vtiger_osstimecontrol.timecontrol_type', 'timecontrol_typeid'])

      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

                          '_type' => $row['timecontrol_type'],

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

                      ];

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

                              $value = 0;

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

                              if ($dataset['_type'] === $timeType) {

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

           * @return string

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

                  ->from('vtiger_osstimecontrol')

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

                  'labels' => [],

      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

                          }

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

              $viewer->assign('DTIME', \App\Fields\Date::formatRangeToDisplay($time));

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

              $viewer->assign('SOURCE_MODULE', 'OSSTimeControl');

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

                  if (!\in_array($row['timecontrol_type'], $timeTypes)) {

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

                      $timeTypes[$row['timecontrol_typeid']] = $row['timecontrol_type'];

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

              if (empty($user)) {

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

                          $dataset['links'][] = 'index.php?module=OSSTimeControl&view=List&viewname=All&entityState=Active' . $this->getSearchParams($user, $data['days'][$index]);

      Line exceeds 120 characters; contains 173 characters
      Open

                          $dataset['links'][] = 'index.php?module=OSSTimeControl&view=List&viewname=All&entityState=Active' . $this->getSearchParams($user, $data['days'][$index]);

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

                  }

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

                      // one dataset per type

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

                                  $dataset['backgroundColor'][] = $colors[$timeTypeId];

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

          public function process(App\Request $request)

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

           * @param int|string $owner

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

              return '&search_params=' . json_encode($listSearchParams);

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

              ])->orderBy('due_date');

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

                  $label = \App\Language::translate($row['timecontrol_type'], 'OSSTimeControl');

      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

              }

      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 (!empty($data['datasets'])) {

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

              $TCPModuleModel = Settings_TimeControlProcesses_Module_Model::getCleanInstance();

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

              $viewer->assign('TCPMODULE_MODEL', $TCPModuleModel->getConfigInstance());

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

                  $viewer->view('dashboards/TimeControlContents.tpl', $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

                          'label' => $label,

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

                          'dataFormatted' => [],

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

                  foreach ($workingTime as $timeValue) {

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

                          if (isset($timeValue[$timeType]) && !empty($timeValue[$timeType])) {

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

                                  // each data item is an different day in this dataset/time type

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

              $time = $request->getDateRange('time');

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

           * @param mixed      $assignedto

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

           *

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

              $listSearchParams[] = $conditions;

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

                  ['>=', 'vtiger_osstimecontrol.due_date', $date[0]],

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

              foreach ($chartData['datasets'] as &$dataset) {

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

                      foreach ($timeTypes as $timeTypeId => $timeType) {

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

                      }

      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

              $user = $request->getByType('user', 2);

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

                  $user = $currentUserId;

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

              $dataReader = $query->createCommand()->query();

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

                      $workingTimeByType[$label] = (float) $row['sum_time'];

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

                          'data' => [],

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

              $dataReader->close();

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

                              $value = $timeValue[$timeType];

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

      class OSSTimeControl_TimeControl_Dashboard extends Vtiger_IndexAjax_View

      The variable $TCPModuleModel is not named in camelCase.
      Open

          public function process(App\Request $request)
          {
              $currentUserId = \App\User::getCurrentUserId();
              $viewer = $this->getViewer($request);
              $moduleName = $request->getModule();

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $TCPModuleModel is not named in camelCase.
      Open

          public function process(App\Request $request)
          {
              $currentUserId = \App\User::getCurrentUserId();
              $viewer = $this->getViewer($request);
              $moduleName = $request->getModule();

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      There are no issues that match your filters.

      Category
      Status