YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Workflows/actions/TaskAjax.php

Summary

Maintainability
D
1 day
Test Coverage
F
0%

Function save has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    public function save(App\Request $request)
    {
        $workflowId = !$request->isEmpty('for_workflow') ? $request->getInteger('for_workflow') : 0;
        if (!empty($workflowId)) {
            $record = !$request->isEmpty('task_id') ? $request->getInteger('task_id') : 0;
Severity: Minor
Found in modules/Settings/Workflows/actions/TaskAjax.php - About 1 day 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 save has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function save(App\Request $request)
    {
        $workflowId = !$request->isEmpty('for_workflow') ? $request->getInteger('for_workflow') : 0;
        if (!empty($workflowId)) {
            $record = !$request->isEmpty('task_id') ? $request->getInteger('task_id') : 0;
Severity: Major
Found in modules/Settings/Workflows/actions/TaskAjax.php - About 3 hrs to fix

    Function changeStatusAllTasks has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        public function changeStatusAllTasks(App\Request $request)
        {
            $record = $request->getInteger('record');
            $status = $request->get('status');
            if (!empty($record)) {
    Severity: Minor
    Found in modules/Settings/Workflows/actions/TaskAjax.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

    Avoid deeply nested control flow statements.
    Open

                                if (!$ownerName) {
                                    $groupRecordModel = Settings_Groups_Record_Model::getInstance($mappingInfo['value']);
                                    $ownerName = $groupRecordModel->getName();
                                }
    Severity: Major
    Found in modules/Settings/Workflows/actions/TaskAjax.php - About 45 mins to fix

      The method save() has an NPath complexity of 25922. The configured NPath complexity threshold is 200.
      Open

          public function save(App\Request $request)
          {
              $workflowId = !$request->isEmpty('for_workflow') ? $request->getInteger('for_workflow') : 0;
              if (!empty($workflowId)) {
                  $record = !$request->isEmpty('task_id') ? $request->getInteger('task_id') : 0;

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

          public function save(App\Request $request)
          {
              $workflowId = !$request->isEmpty('for_workflow') ? $request->getInteger('for_workflow') : 0;
              if (!empty($workflowId)) {
                  $record = !$request->isEmpty('task_id') ? $request->getInteger('task_id') : 0;

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

          public function save(App\Request $request)

      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 '84', column '20').
      Open

                  $response = new Vtiger_Response();

      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 '182', column '20').
      Open

                  $response = new Vtiger_Response();

      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 '31', column '20').
      Open

                  $response = new Vtiger_Response();

      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 '49', column '20').
      Open

                  $response = new Vtiger_Response();

      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 'Settings_Workflows_Record_Model' in method 'changeStatusAllTasks'.
      Open

                  $workflowModel = Settings_Workflows_Record_Model::getInstance($record);

      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_Workflows_TaskRecord_Model' in method 'save'.
      Open

                      $taskRecordModel = Settings_Workflows_TaskRecord_Model::getInstance($record);

      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\Json' in method 'save'.
      Open

                              $values = \App\Json::decode($request->getRaw($fieldName));

      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_Workflows_Record_Model' in method 'save'.
      Open

                      $workflowModel = Settings_Workflows_Record_Model::getInstance($workflowId);

      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\Json' in method 'save'.
      Open

                      $fieldMapping = \App\Json::decode($taskObject->field_value_mapping);

      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\Json' in method 'save'.
      Open

                      $taskObject->field_value_mapping = \App\Json::encode($fieldMapping);

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Users_Record_Model' in method 'save'.
      Open

                                  $userRecordModel = Users_Record_Model::getInstanceById($mappingInfo['value'], 'Users');

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

                  } else {
                      $workflowModel = Settings_Workflows_Record_Model::getInstance($workflowId);
                      $taskRecordModel = Settings_Workflows_TaskRecord_Model::getCleanInstance($workflowModel, $request->get('taskType'));
                      $taskObject = $taskRecordModel->getTaskObject();
                      $taskObject->sequence = $taskRecordModel->getNextSequenceNumber($workflowId);

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

                              } else {
                                  $taskObject->{$fieldName} = \App\Purifier::decodeHtml($request->getForHtml($fieldName));
                              }

      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_Module_Model' in method 'save'.
      Open

                      $relationModuleModel = Vtiger_Module_Model::getInstance($taskObject->entity_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 '\App\Condition' in method 'save'.
      Open

                      $taskObject->conditions = \App\Condition::getConditionsFromRequest($taskObject->conditions);

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

                      } else {
                          $taskObject->active = false;
                      }

      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_Workflows_TaskRecord_Model' in method 'save'.
      Open

                      $taskRecordModel = Settings_Workflows_TaskRecord_Model::getCleanInstance($workflowModel, $request->get('taskType'));

      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_Workflows_TaskRecord_Model' in method 'changeStatus'.
      Open

                  $taskRecordModel = Settings_Workflows_TaskRecord_Model::getInstance($record);

      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\Purifier' in method 'save'.
      Open

                                  $taskObject->{$fieldName} = \App\Purifier::decodeHtml($request->getForHtml($fieldName));

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

                  } else {
                      $taskObject->active = false;
                  }

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

                  } else {
                      $taskObject->trigger = null;
                  }

      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_Groups_Record_Model' in method 'save'.
      Open

                                      $groupRecordModel = Settings_Groups_Record_Model::getInstance($mappingInfo['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

      Avoid using static access to class 'Settings_Workflows_TaskRecord_Model' in method 'delete'.
      Open

                  $taskRecordModel = Settings_Workflows_TaskRecord_Model::getInstance($record);

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

                          } else {
                              $taskObject->{$fieldName} = $request->get($fieldName);
                          }

      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\Purifier' in method 'save'.
      Open

                  $taskObject->summary = \App\Purifier::decodeHtml($request->getByType('summary', \App\Purifier::TEXT));

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

                  } else {
                      $fieldNames = $taskObject->getFieldNames();
                      $fieldNamesRequestMethods = method_exists($taskObject, 'getFieldsNamesRequestMethod') ? $taskObject->getFieldsNamesRequestMethod() : [];
                      foreach ($fieldNames as $fieldName) {
                          if ('field_value_mapping' == $fieldName || 'content' == $fieldName) {

      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\Json' in method 'save'.
      Open

                                  $taskObject->{$fieldName} = \App\Json::encode($values);

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

              $record = $request->get('task_id');

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

                                      $values[$index]['value'] = htmlspecialchars($value['value']);

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

              $workflowId = !$request->isEmpty('for_workflow') ? $request->getInteger('for_workflow') : 0;

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Call to undeclared method \VTTask::save
      Open

                  $taskRecordModel->save();

      Call to undeclared method \VTTask::getNextSequenceNumber
      Open

                      $taskObject->sequence = $taskRecordModel->getNextSequenceNumber($workflowId);

      Call to undeclared method \VTTask::delete
      Open

                  $taskRecordModel->delete();

      Call to undeclared method \VTTask::getTaskObject
      Open

                  $taskObject = $taskRecordModel->getTaskObject();

      Call to undeclared method \VTTask::save
      Open

                  $taskRecordModel->save();

      Call to undeclared method \VTTask::getTaskObject
      Open

                      $taskObject = $taskRecordModel->getTaskObject();

      Call to undeclared method \VTTask::getTaskObject
      Open

                      $taskObject = $taskRecordModel->getTaskObject();

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

                      $fieldNamesRequestMethods = method_exists($taskObject, 'getFieldsNamesRequestMethod') ? $taskObject->getFieldsNamesRequestMethod() : [];

      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 Settings_Workflows_TaskAjax_Action extends Settings_Vtiger_Basic_Action

      The class Settings_Workflows_TaskAjax_Action is not named in CamelCase.
      Open

      class Settings_Workflows_TaskAjax_Action extends Settings_Vtiger_Basic_Action
      {
          use \App\Controller\ExposeMethod;
      
          public function __construct()

      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

          public function __construct()

      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->emit();

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

                  $taskObject = $taskRecordModel->getTaskObject();

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

          }

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

                  $taskRecordModel = Settings_Workflows_TaskRecord_Model::getInstance($record);

      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

          {

      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

                      $taskObject->active = true;

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

          public function changeStatus(App\Request $request)

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

                  if ('true' == $request->get('status')) {

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

              $this->exposeMethod('changeStatusAllTasks');

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

                  $taskRecordModel = Settings_Workflows_TaskRecord_Model::getInstance($record);

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

                      $taskObject->active = false;

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

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

          {

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

              $record = $request->get('task_id');

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

              if (!empty($record)) {

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

              if (!empty($record)) {

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

                  $taskRecordModel->delete();

      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

                      $workflowModel = Settings_Workflows_Record_Model::getInstance($workflowId);

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

                      $fieldNamesRequestMethods = method_exists($taskObject, 'getFieldsNamesRequestMethod') ? $taskObject->getFieldsNamesRequestMethod() : [];

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

                                  if (!$ownerName) {

      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

                  $response->setResult(['ok']);

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

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

          public function changeStatusAllTasks(App\Request $request)

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

                  foreach ($taskList as $taskRecordModel) {

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

                      $taskRecordModel = Settings_Workflows_TaskRecord_Model::getCleanInstance($workflowModel, $request->get('taskType'));

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

                      $taskObject = $taskRecordModel->getTaskObject();

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

                  $active = $request->get('active');

      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

                      $trigger = [

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

                  } elseif ('false' == $active) {

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

                              if (\is_array($values)) {

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

                      $taskObject->trigger = $trigger;

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

                                  foreach ($values as $index => $value) {

      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 ($fieldNames as $fieldName) {

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

                                      $values[$index]['value'] = htmlspecialchars($value['value']);

      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 ('SumFieldFromDependent' === $taskType && $taskObject->conditions) {

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

          }

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

                      $relationModuleModel = Vtiger_Module_Model::getInstance($taskObject->entity_type);

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

                      $taskObject = $taskRecordModel->getTaskObject();

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

                          $taskObject->active = 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

           * @return 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

                      $taskObject->active = true;

      Line exceeds 120 characters; contains 133 characters
      Open

                          'days' => ('after' == $request->get('select_date_direction') ? 1 : -1) * (int) $request->get('select_date_days'),

      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

                      $taskObject->setDataFromRequest($request);

      Line exceeds 120 characters; contains 152 characters
      Open

                      $fieldNamesRequestMethods = method_exists($taskObject, 'getFieldsNamesRequestMethod') ? $taskObject->getFieldsNamesRequestMethod() : [];

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

                      foreach ($fieldMapping as $key => $mappingInfo) {

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

                              } elseif ('triggerUser' !== $mappingInfo['value']) {

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

                  $taskRecordModel->save();

      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

           * @return void

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

              if (!empty($record)) {

      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

           * Save.

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

          public function save(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

                      $ownerFieldModels = $relationModuleModel->getFieldsByType('owner');

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

                                      $ownerName = $groupRecordModel->getName();

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

          /**

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

                  $activeCount = 0;

      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

           * Change status for all workflow tasks.

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

              $status = $request->get('status');

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

              $workflowId = !$request->isEmpty('for_workflow') ? $request->getInteger('for_workflow') : 0;

      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

              if (!empty($workflowId)) {

      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

                  $taskObject->summary = \App\Purifier::decodeHtml($request->getByType('summary', \App\Purifier::TEXT));

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

                      $taskObject->active = false;

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

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

                                  $taskObject->{$fieldName} = \App\Json::encode($values);

      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

           * @param 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

                      $taskRecordModel->save();

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

          {

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

                  $record = !$request->isEmpty('task_id') ? $request->getInteger('task_id') : 0;

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

                      $taskRecordModel = Settings_Workflows_TaskRecord_Model::getInstance($record);

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

                      $fieldNames = $taskObject->getFieldNames();

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

                              $values = \App\Json::decode($request->getRaw($fieldName));

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

                              }

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

                          } elseif (isset($fieldNamesRequestMethods[$fieldName])) {

      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

                  foreach ($taskList as $taskRecord) {

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

                          ++$activeCount;

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

                          'days' => ('after' == $request->get('select_date_direction') ? 1 : -1) * (int) $request->get('select_date_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

                              } else {

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

                  $taskType = \get_class($taskObject);

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

           */

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

                      $taskObject->conditions = \App\Condition::getConditionsFromRequest($taskObject->conditions);

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

                      $taskObject = $taskRecordModel->getTaskObject();

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

                  $checkSelectDate = $request->get('check_select_date');

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

                          'field' => $request->getByType('select_date_field', \App\Purifier::ALNUM),

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

                                  $ownerName = $userRecordModel->get('user_name');

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

                      $taskObject->field_value_mapping = \App\Json::encode($fieldMapping);

      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

              $record = $request->getInteger('record');

      Line exceeds 120 characters; contains 132 characters
      Open

                      $taskRecordModel = Settings_Workflows_TaskRecord_Model::getCleanInstance($workflowModel, $request->get('taskType'));

      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 (method_exists($taskObject, 'setDataFromRequest')) {

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

                                  $taskObject->{$fieldName} = \App\Purifier::decodeHtml($request->getForHtml($fieldName));

      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

                      $fieldMapping = \App\Json::decode($taskObject->field_value_mapping);

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

                          if (\array_key_exists($mappingInfo['fieldname'], $ownerFieldModels)) {

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

                              if ('assigned_user_id' == $mappingInfo['value']) {

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

                                  $fieldMapping[$key]['value'] = $ownerName;

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

                  $taskRecordModel->save();

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

              $this->exposeMethod('save');

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

          public function delete(App\Request $request)

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

                          $taskObject->active = false;

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

                      if ($taskRecord->isActive() && $taskRecord->isEditable()) {

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

                              $taskObject->{$fieldName} = $request->{$fieldNamesRequestMethods[$fieldName]}($fieldName);

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

                  if ('VTCreateEntityTask' === $taskType && $taskObject->field_value_mapping) {

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

                                  $fieldMapping[$key]['valuetype'] = 'fieldname';

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

                  $taskList = $workflowModel->getTasks(false);

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

          /**

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

                      $taskObject->sequence = $taskRecordModel->getNextSequenceNumber($workflowId);

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

                  }

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

                                  $userRecordModel = Users_Record_Model::getInstanceById($mappingInfo['value'], 'Users');

      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

                  $response->emit();

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

                  $response->setResult(['success' => true, 'count' => $activeCount]);

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

                  if ('true' == $active) {

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

                      $taskObject->trigger = null;

      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

                  $response->setResult(['for_workflow' => $workflowId]);

      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

              $this->exposeMethod('delete');

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

              $record = $request->get('task_id');

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

                  $response->setResult(['ok']);

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

                  $workflowModel = Settings_Workflows_Record_Model::getInstance($record);

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

                      if ('true' == $status) {

      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->emit();

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

                          if ('field_value_mapping' == $fieldName || 'content' == $fieldName) {

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

                              $taskObject->{$fieldName} = $request->get($fieldName);

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

                                      $groupRecordModel = Settings_Groups_Record_Model::getInstance($mappingInfo['value']);

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

                  $response->emit();

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

      class Settings_Workflows_TaskAjax_Action extends Settings_Vtiger_Basic_Action

      There are no issues that match your filters.

      Category
      Status