Function doTask
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
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 doTask
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
The method doTask() has an NPath complexity of 2446080. The configured NPath complexity threshold is 200. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
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 doTask() has 163 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Exclude checks
The method doTask() has a Cyclomatic Complexity of 31. The configured cyclomatic complexity threshold is 10. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
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
This function "doTask" has 162 lines, which is greater than the 150 lines authorized. Split it into smaller functions. Open
public function doTask($recordModel)
- Read upRead up
- Exclude checks
A function that grows too large tends to aggregate too many responsibilities.
Such functions inevitably become harder to understand and therefore harder to maintain.
Above a specific threshold, it is strongly advised to refactor into smaller functions which focus on well-defined tasks.
Those smaller functions will not only be easier to understand, but also probably easier to test.
Refactor this function to reduce its Cognitive Complexity from 53 to the 15 allowed. Open
public function doTask($recordModel)
- Read upRead up
- Exclude checks
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
The class VTCreateTodoTask has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13. Open
class VTCreateTodoTask extends VTTask
{
public $executeImmediately = true;
public function getFieldNames()
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '70', column '23'). Open
$userExists = (new App\Db\Query())->from('vtiger_users')
- Read upRead up
- Exclude checks
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 '76', column '24'). Open
$groupExist = (new App\Db\Query())->from('vtiger_groups')
- Read upRead up
- Exclude checks
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 '43', column '18'). Open
$query = (new App\Db\Query())->from('vtiger_activity')
- Read upRead up
- Exclude checks
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 'vtlib\Functions' in method 'doTask'. Open
$status = vtlib\Functions::getArrayFromValue($this->duplicateStatus);
- Read upRead up
- Exclude checks
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 'DateTimeField' in method 'doTask'. Open
$dbInsertDateTime = DateTimeField::convertToDBTimeZone($baseDateEnd . ' ' . $timeWithSec);
- Read upRead up
- Exclude checks
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 doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dueDateTime = date('Y-m-d H:i:s', strtotime($date_start . ' ' . $time) + $endIncrement);
$dueDateTime = explode(' ', $dueDateTime);
$due_date = $dueDateTime[0];
$timeEnd = $dueDateTime[1];
- Read upRead up
- Exclude checks
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_Record_Model' in method 'doTask'. Open
$newRecordModel = Vtiger_Record_Model::getCleanInstance('Calendar');
- Read upRead up
- Exclude checks
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 'DateTimeField' in method 'doTask'. Open
$dbInsertDateTime = DateTimeField::convertToDBTimeZone($baseDateStart . ' ' . $timeWithSec);
- Read upRead up
- Exclude checks
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 doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$baseDateEnd = $recordModel->get($this->datefield_end);
if ('' == $baseDateEnd) {
$baseDateEnd = date('Y-m-d');
}
- Read upRead up
- Exclude checks
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 doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$groupExist = (new App\Db\Query())->from('vtiger_groups')
->where(['groupid' => $this->assigned_user_id])
->exists();
if ($groupExist) {
- Read upRead up
- Exclude checks
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 assigning values to variables in if clauses and the like (line '166', column '8'). Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
The method doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$baseDateStart = $recordModel->get($this->datefield_start);
if ('' == $baseDateStart) {
$baseDateStart = date('Y-m-d');
}
- Read upRead up
- Exclude checks
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\Record' in method 'doTask'. Open
if ($parentRecord = \App\Record::getParentRecord($parentRecord)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Vtiger_Relation_Model' in method 'doTask'. Open
$relationModel = \Vtiger_Relation_Model::getInstance($recordModel->getModule(), $newRecordModel->getModule());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\ModuleHierarchy' in method 'doTask'. Open
$field = \App\ModuleHierarchy::getMappingRelatedField($parentModuleName);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '160', column '7'). Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\App\Log' in method 'doTask'. Open
\App\Log::trace('Start ' . __CLASS__ . ':' . __FUNCTION__);
- Read upRead up
- Exclude checks
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\Double' in method 'doTask'. Open
$endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1);
- Read upRead up
- Exclude checks
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\PrivilegeUtil' in method 'doTask'. Open
} elseif ($userIdFromGroup = current(\App\PrivilegeUtil::getUsersByGroup($userId))) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\ModuleHierarchy' in method 'doTask'. Open
$field = \App\ModuleHierarchy::getMappingRelatedField($parentModuleName);
- Read upRead up
- Exclude checks
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\Log' in method 'doTask'. Open
\App\Log::trace('End ' . __CLASS__ . ':' . __FUNCTION__);
- Read upRead up
- Exclude checks
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 'doTask'. Open
$timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Module' in method 'doTask'. Open
if (!\App\Module::isModuleActive('Calendar')) {
- Read upRead up
- Exclude checks
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 doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour');
}
- Read upRead up
- Exclude checks
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 assigning values to variables in if clauses and the like (line '120', column '15'). Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\App\Fields\Time' in method 'doTask'. Open
$timeWithSec = \App\Fields\Time::sanitizeDbFormat($this->time);
- Read upRead up
- Exclude checks
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\Time' in method 'doTask'. Open
$timeWithSec = \App\Fields\Time::sanitizeDbFormat($timeEnd);
- Read upRead up
- Exclude checks
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 'doTask'. Open
if (\App\User::isExists($userId)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\ModuleHierarchy' in method 'doTask'. Open
$field = \App\ModuleHierarchy::getMappingRelatedField($moduleName);
- Read upRead up
- Exclude checks
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 'doTask'. Open
$userId = \App\User::getCurrentUserId();
- Read upRead up
- Exclude checks
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\Record' in method 'doTask'. Open
if ($parentRecord = \App\Record::getParentRecord($recordModel->getId())) {
- Read upRead up
- Exclude checks
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' in method 'doTask'. Open
$userId = Users::getActiveAdminUser();
- Read upRead up
- Exclude checks
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\TextParser' in method 'doTask'. Open
$textParser = \App\TextParser::getInstanceByModel($recordModel);
- Read upRead up
- Exclude checks
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\Record' in method 'doTask'. Open
$parentModuleName = \App\Record::getType($parentRecord);
- Read upRead up
- Exclude checks
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 conv12to24hour uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$hours = ((int) $arr[1]) % 12 + 12;
}
- Read upRead up
- Exclude checks
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\Record' in method 'doTask'. Open
$parentModuleName = \App\Record::getType($parentRecord);
- Read upRead up
- Exclude checks
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\Log' in method 'doTask'. Open
\App\Log::warning(__CLASS__ . '::' . __METHOD__ . ': To Do was ignored because a duplicate was found.' . $this->todo);
- Read upRead up
- Exclude checks
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 doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$time = $time[1];
}
- Read upRead up
- Exclude checks
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 doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$timeEnd = $timeEnd[1];
}
- Read upRead up
- Exclude checks
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
Define a constant instead of duplicating this literal "end_hour" 3 times. Open
$timeEnd = \App\User::getUserModel($userId)->getDetail('end_hour');
- Read upRead up
- Exclude checks
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 "assigned_user_id" 4 times. Open
return ['todo', 'description', 'time', 'days_start', 'days_end', 'status', 'priority', 'days', 'direction_start', 'datefield_start', 'direction_end', 'datefield_end', 'sendNotification', 'assigned_user_id', 'days', 'doNotDuplicate', 'duplicateStatus', 'updateDates'];
- Read upRead up
- Exclude checks
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 "Y-m-d H:i:s" 3 times. Open
$baseDateStart = date('Y-m-d H:i:s');
- Read upRead up
- Exclude checks
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.
Reference to undeclared property \VTCreateTodoTask->duplicateStatus
Open
$status = vtlib\Functions::getArrayFromValue($this->duplicateStatus);
- Exclude checks
Call to method warning
from undeclared class \App\Log
Open
\App\Log::warning(__CLASS__ . '::' . __METHOD__ . ': To Do was ignored because a duplicate was found.' . $this->todo);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$groupExist = (new App\Db\Query())->from('vtiger_groups')
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->assigned_user_id
Open
if ('currentUser' === $this->assigned_user_id) {
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->assigned_user_id
Open
} elseif ('copyParentOwner' === $this->assigned_user_id) {
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$userExists = (new App\Db\Query())->from('vtiger_users')
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->todo
Open
\App\Log::warning(__CLASS__ . '::' . __METHOD__ . ': To Do was ignored because a duplicate was found.' . $this->todo);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$query = (new App\Db\Query())->from('vtiger_activity')
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->assigned_user_id
Open
$userId = $this->assigned_user_id;
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->datefield_start
Open
$baseDateStart = $recordModel->get($this->datefield_start);
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->direction_start
Open
$date_start = strftime('%Y-%m-%d', $baseDateStart + (int) $this->days_start * 24 * 60 * 60 * ('before' == strtolower($this->direction_start) ? -1 : 1));
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->datefield_end
Open
if ('fromDateStart' !== $this->datefield_end) {
- Exclude checks
Call to method isExists
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
if (\App\User::isExists($userId)) {
- Exclude checks
Call to method getActiveAdminId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour');
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->todo
Open
['vtiger_activity.subject' => $this->todo],
- Exclude checks
Reference to undeclared property \Vtiger_Record_Model->executeUser
Open
$userId = $recordModel->executeUser;
- Exclude checks
Call to method getUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$timeEnd = \App\User::getUserModel($userIdFromGroup)->getDetail('end_hour');
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
App\Db::getInstance()->createCommand()->insert('vtiger_activity_update_dates', [
- Exclude checks
Argument 1 (input)
is int
but \str_pad()
takes string
Open
return str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($arr[2], 2, '0', STR_PAD_LEFT);
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Start ' . __CLASS__ . ':' . __FUNCTION__);
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->assigned_user_id
Open
->where(['id' => $this->assigned_user_id, 'status' => 'Active'])
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->assigned_user_id
Open
->where(['groupid' => $this->assigned_user_id])
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->assigned_user_id
Open
$userId = $this->assigned_user_id;
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->priority
Open
'taskpriority' => $this->priority,
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->sendNotification
Open
'sendnotification' => ('' != $this->sendNotification && 'N' != $this->sendNotification),
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->days_end
Open
$endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1);
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->assigned_user_id
Open
} elseif (!empty($this->assigned_user_id)) { // Added to check if the user/group is active
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->assigned_user_id
Open
} elseif ('triggerUser' === $this->assigned_user_id) {
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->datefield_end
Open
if ('wfRunTime' == $this->datefield_end) {
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$userId = \App\User::getCurrentUserId();
- Exclude checks
Call to method getInstanceByModel
from undeclared class \App\TextParser
(Did you mean class \Tests\App\TextParser) Open
$textParser = \App\TextParser::getInstanceByModel($recordModel);
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->status
(Did you mean $status) Open
'activitystatus' => $this->status,
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('End ' . __CLASS__ . ':' . __FUNCTION__);
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->time
(Did you mean $time) Open
$timeWithSec = \App\Fields\Time::sanitizeDbFormat($this->time);
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->days_start
Open
$date_start = strftime('%Y-%m-%d', $baseDateStart + (int) $this->days_start * 24 * 60 * 60 * ('before' == strtolower($this->direction_start) ? -1 : 1));
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->datefield_end
Open
$baseDateEnd = $recordModel->get($this->datefield_end);
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->direction_end
Open
$endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1);
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->description
Open
'description' => $textParser->setContent($this->description)->parse()->getContent(),
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->doNotDuplicate
Open
if ('true' == $this->doNotDuplicate) {
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->datefield_start
Open
if ('wfRunTime' == $this->datefield_start) {
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->id
Open
'task_id' => $this->id,
- Exclude checks
Call to method getUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$timeEnd = \App\User::getUserModel($userId)->getDetail('end_hour');
- Exclude checks
Call to method getUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour');
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->updateDates
Open
if ('true' == $this->updateDates) {
- Exclude checks
Reference to undeclared property \VTCreateTodoTask->todo
Open
'subject' => $textParser->setContent($this->todo)->parse()->getContent(),
- Exclude checks
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ('currentUser' === $this->assigned_user_id) {
$userId = \App\User::getCurrentUserId();
} elseif ('triggerUser' === $this->assigned_user_id) {
$userId = $recordModel->executeUser;
} elseif ('copyParentOwner' === $this->assigned_user_id) {
- Read upRead up
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 178.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
public static function conv12to24hour($timeStr)
{
$arr = [];
preg_match('/(\d{1,2}):(\d{1,2})(am|pm)/', $timeStr, $arr);
if ('am' == $arr[3]) {
- Read upRead up
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 139.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($parentRecord = \App\Record::getParentRecord($recordModel->getId())) {
$parentModuleName = \App\Record::getType($parentRecord);
$field = \App\ModuleHierarchy::getMappingRelatedField($parentModuleName);
if ($field) {
$fields[$field] = $parentRecord;
- Read upRead up
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 105.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class VTCreateTodoTask extends VTTask
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 15 and the first side effect is on line 11. Open
<?php
- Exclude checks
Line exceeds 120 characters; contains 275 characters Open
return ['todo', 'description', 'time', 'days_start', 'days_end', 'status', 'priority', 'days', 'direction_start', 'datefield_start', 'direction_end', 'datefield_end', 'sendNotification', 'assigned_user_id', 'days', 'doNotDuplicate', 'duplicateStatus', 'updateDates'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null === $userId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$entityId = $recordModel->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$status = vtlib\Functions::getArrayFromValue($this->duplicateStatus);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($query->count() > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$time = explode(' ', $baseDateStart);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$time = $time[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\count($time) < 2) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'taskpriority' => $this->priority,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('triggerUser' === $this->assigned_user_id) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$groupExist = (new App\Db\Query())->from('vtiger_groups')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['groupid' => $this->assigned_user_id])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$baseDateStart = strtotime($match[0]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\User::isExists($userId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDateEnd, $match);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userId = $recordModel->executeUser;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('copyParentOwner' === $this->assigned_user_id) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$baseDateEnd = date('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'subject' => $textParser->setContent($this->todo)->parse()->getContent(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userId = $recordModel->get('assigned_user_id');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$due_date = strftime('%Y-%m-%d ', $baseDateEnd + $endIncrement);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$textParser = \App\TextParser::getInstanceByModel($recordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function doTask($recordModel)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userId = Users::getActiveAdminUser();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'and',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$baseDateEnd = $recordModel->get($this->datefield_end);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeEnd = \App\User::getUserModel($userIdFromGroup)->getDetail('end_hour');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeEnd = $timeEnd[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'description' => $textParser->setContent($this->description)->parse()->getContent(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('currentUser' === $this->assigned_user_id) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dueDateTime = date('Y-m-d H:i:s', strtotime($date_start . ' ' . $time) + $endIncrement);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$due_date = $dueDateTime[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFieldNames()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['or', ['vtiger_activity.link' => $entityId], ['vtiger_activity.process' => $entityId]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::warning(__CLASS__ . '::' . __METHOD__ . ': To Do was ignored because a duplicate was found.' . $this->todo);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->exists();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$baseDateStart = $recordModel->get($this->datefield_start);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeWithSec = \App\Fields\Time::sanitizeDbFormat($timeEnd);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $executeImmediately = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userId = $recordModel->get('assigned_user_id');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['vtiger_activity.subject' => $this->todo],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userId = \App\User::getCurrentUserId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($userExists) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('' == $baseDateStart) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('wfRunTime' == $this->datefield_end) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('true' == $this->doNotDuplicate) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['vtiger_crmentity.deleted' => 0],
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
\App\Log::warning(__CLASS__ . '::' . __METHOD__ . ': To Do was ignored because a duplicate was found.' . $this->todo);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['id' => $this->assigned_user_id, 'status' => 'Active'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userId = $this->assigned_user_id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDateStart, $match);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeEnd = \App\User::getUserModel($userId)->getDetail('end_hour');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Execute task.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\App\Module::isModuleActive('Calendar')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('Start ' . __CLASS__ . ':' . __FUNCTION__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = vtiger_activity.activityid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\count($status) > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbInsertDateTime = DateTimeField::convertToDBTimeZone($baseDateStart . ' ' . $timeWithSec);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$time = $dbInsertDateTime->format('H:i:s');
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
$endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeEnd = explode(' ', $baseDateEnd);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbInsertDateTime = DateTimeField::convertToDBTimeZone($baseDateEnd . ' ' . $timeWithSec);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $recordModel->getModuleName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new App\Db\Query())->from('vtiger_activity')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$baseDateEnd = strtotime($match[0]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dueDateTime = explode(' ', $dueDateTime);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeEnd = $dueDateTime[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return ['todo', 'description', 'time', 'days_start', 'days_end', 'status', 'priority', 'days', 'direction_start', 'datefield_start', 'direction_end', 'datefield_end', 'sendNotification', 'assigned_user_id', 'days', 'doNotDuplicate', 'duplicateStatus', 'updateDates'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userId = $this->assigned_user_id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$date_start = strftime('%Y-%m-%d', $baseDateStart + (int) $this->days_start * 24 * 60 * 60 * ('before' == strtolower($this->direction_start) ? -1 : 1));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('fromDateStart' !== $this->datefield_end) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeEnd = $dbInsertDateTime->format('H:i:s');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'parent' => $recordModel->getId(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$field = \App\ModuleHierarchy::getMappingRelatedField($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('End ' . __CLASS__ . ':' . __FUNCTION__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$baseDateStart = date('Y-m-d H:i:s');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeWithSec = \App\Fields\Time::sanitizeDbFormat($this->time);
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
$date_start = strftime('%Y-%m-%d', $baseDateStart + (int) $this->days_start * 24 * 60 * 60 * ('before' == strtolower($this->direction_start) ? -1 : 1));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$baseDateEnd = date('Y-m-d H:i:s');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($userIdFromGroup = current(\App\PrivilegeUtil::getUsersByGroup($userId))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'activitystatus' => $this->status,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newRecordModel->setData($fields);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
App\Db::getInstance()->createCommand()->insert('vtiger_activity_update_dates', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (!empty($this->assigned_user_id)) { // Added to check if the user/group is active
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->exists();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($groupExist) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('wfRunTime' == $this->datefield_start) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentModuleName = \App\Record::getType($parentRecord);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$field = \App\ModuleHierarchy::getMappingRelatedField($parentModuleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newRecordModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match('/(\d{1,2}):(\d{1,2})(am|pm)/', $timeStr, $arr);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return ['time'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['vtiger_activity.activitytype' => 'Task'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['not in', 'vtiger_activity.status', $status]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userExists = (new App\Db\Query())->from('vtiger_users')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$baseDateStart = date('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('' == $baseDateEnd) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\count($timeEnd) < 2) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'activitytype' => 'Task',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newRecordModel->setHandlerExceptions(['disableHandlerClasses' => ['Vtiger_Workflow_Handler']]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationModel->addRelation($recordModel->getId(), $newRecordModel->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'due_date' => $due_date,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($arr[2], 2, '0', STR_PAD_LEFT);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'assigned_user_id' => $userId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newRecordModel = Vtiger_Record_Model::getCleanInstance('Calendar');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($relationModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$arr = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'time_end' => $timeEnd,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'visibility' => 'Private',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields[$field] = $parentRecord;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($parentRecord = \App\Record::getParentRecord($parentRecord)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'time_start' => $time,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function conv12to24hour($timeStr)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getTimeFieldList()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentModuleName = \App\Record::getType($parentRecord);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$field = \App\ModuleHierarchy::getMappingRelatedField($parentModuleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields[$field] = $parentRecord;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('true' == $this->updateDates) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationModel = \Vtiger_Relation_Model::getInstance($recordModel->getModule(), $newRecordModel->getModule());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'activityid' => $newRecordModel->getId(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('am' == $arr[3]) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sendnotification' => ('' != $this->sendNotification && 'N' != $this->sendNotification),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'task_id' => $this->id,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields[$field] = $recordModel->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$hours = ((int) $arr[1]) % 12 + 12;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'date_start' => $date_start,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($parentRecord = \App\Record::getParentRecord($recordModel->getId())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$hours = ((int) $arr[1]) % 12;
- Exclude checks
The variable $date_start is not named in camelCase. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
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 $date_start is not named in camelCase. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
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 $due_date is not named in camelCase. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
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 $due_date is not named in camelCase. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
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 $date_start is not named in camelCase. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
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 $due_date is not named in camelCase. Open
public function doTask($recordModel)
{
if (!\App\Module::isModuleActive('Calendar')) {
return;
}
- Read upRead up
- Exclude checks
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();
}
}