Function getEmployeeHierarchy
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function getEmployeeHierarchy($id)
{
\App\Log::trace('Entering getEmployeeHierarchy(' . $id . ') method ...');
$listViewHeader = [];
- 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
Function __getChildEmployees
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function __getChildEmployees($id, &$childAccounts, $depth)
{
$userNameSql = App\Module::getSqlForNameInDisplayFormat('Users');
$dataReader = (new App\Db\Query())
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- 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 getEmployeeHierarchy
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getEmployeeHierarchy($id)
{
\App\Log::trace('Entering getEmployeeHierarchy(' . $id . ') method ...');
$listViewHeader = [];
The class OSSEmployees has 18 fields. Consider redesigning OSSEmployees to keep the number of fields under 15. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Method __getParentEmployees
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __getParentEmployees($id, &$parentAccounts, &$encounteredAccounts)
{
$parentId = (new App\Db\Query())
->select(['parentid'])
->from('vtiger_ossemployees')
Method __getChildEmployees
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __getChildEmployees($id, &$childAccounts, $depth)
{
$userNameSql = App\Module::getSqlForNameInDisplayFormat('Users');
$dataReader = (new App\Db\Query())
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
Function __getParentEmployees
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function __getParentEmployees($id, &$parentAccounts, &$encounteredAccounts)
{
$parentId = (new App\Db\Query())
->select(['parentid'])
->from('vtiger_ossemployees')
- 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
Function moduleHandler
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function moduleHandler($moduleName, $eventType)
{
if ('module.postinstall' == $eventType) {
//block with fields in summary
$tabId = \App\Module::getModuleId($moduleName);
- 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
The method getEmployeeHierarchy() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function getEmployeeHierarchy($id)
{
\App\Log::trace('Entering getEmployeeHierarchy(' . $id . ') method ...');
$listViewHeader = [];
- 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
Refactor this function to reduce its Cognitive Complexity from 29 to the 15 allowed. Open
public function getEmployeeHierarchy($id)
- 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
Missing class import via use statement (line '147', column '16'). Open
$data = (new App\Db\Query())
- 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 '178', column '58'). Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- 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 '137', column '20'). Open
$parentId = (new App\Db\Query())
- 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 '148', column '58'). Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- 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 '177', column '22'). Open
$dataReader = (new App\Db\Query())
- 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
The method __getChildEmployees uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$childAccountInfo[$columnName] = $row[$columnName];
}
- 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 getEmployeeHierarchy uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$data = '<i>' . $data . '</i>';
}
- 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\Field' in method 'getEmployeeHierarchy'. Open
} elseif (\App\Field::getFieldPermission('OSSEmployees', $colName)) {
- 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\Purifier' in method 'getEmployeeHierarchy'. Open
$data = \App\Purifier::encodeHtml($accountInfo[$colName]);
- 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 __getParentEmployees uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$parentAccountInfo[$columnName] = $data[$columnName];
}
- 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\Module' in method '__getChildEmployees'. Open
$userNameSql = App\Module::getSqlForNameInDisplayFormat('Users');
- 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\Field' in method 'getEmployeeHierarchy'. Open
if (\App\Field::getFieldPermission('OSSEmployees', $colName)) {
- 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 getEmployeeHierarchy uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$data = '<b>' . $data . '</b>';
}
- 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\Log' in method 'getEmployeeHierarchy'. Open
\App\Log::trace('Exiting getEmployeeHierarchy method ...');
- 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 '__getParentEmployees'. Open
$userNameSql = App\Module::getSqlForNameInDisplayFormat('Users');
- 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 'getEmployeeHierarchy'. Open
\App\Log::trace('Entering getEmployeeHierarchy(' . $id . ') method ...');
- 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 'moduleHandler'. Open
$tabId = \App\Module::getModuleId($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 'vtlib\Module' in method 'moduleHandler'. Open
$modcommentsModuleInstance = vtlib\Module::getInstance('ModComments');
- 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 'ModComments' in method 'moduleHandler'. Open
ModComments::addWidgetTo(['OSSEmployees']);
- 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\Language' in method 'getEmployeeHierarchy'. Open
$listViewHeader[] = \App\Language::translate($fieldName);
- 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\Privilege' in method 'getEmployeeHierarchy'. Open
$hasRecordViewAccess = \App\Privilege::isPermitted('OSSEmployees', 'DetailView', $employeesId);
- 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
Define a constant instead of duplicating this literal "ossemployeesid" 5 times. Open
public $table_index = 'ossemployeesid';
- 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 "last_name" 6 times. Open
'LBL_LASTNAME' => 'last_name',
- 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 "depth" 5 times. Open
$rowsList = $this->__getChildEmployees($id, $rowsList, $rowsList[$id]['depth']);
- 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
'Assigned To' => 'assigned_user_id',
- 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 "ossemployees" 4 times. Open
'LBL_LASTNAME' => ['ossemployees', 'last_name'],
- 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 "vtiger_crmentity" 5 times. Open
public $tab_name = ['vtiger_crmentity', 'vtiger_ossemployees', 'vtiger_ossemployeescf', 'vtiger_entity_stats'];
- 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 "vtiger_ossemployees" 6 times. Open
public $table_name = 'vtiger_ossemployees';
- 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 "vtiger_ossemployees.ossemployeesid = vtiger_crmentity.crmid" 3 times. Open
->innerJoin('vtiger_crmentity', 'vtiger_ossemployees.ossemployeesid = vtiger_crmentity.crmid')
- 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 "parentid" 4 times. Open
} elseif ('parentid' == $colName) {
- 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 "OSSEmployees" 5 times. Open
if (\App\Field::getFieldPermission('OSSEmployees', $colName)) {
- 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 "business_mail" 3 times. Open
'LBL_BUSINESSMAIL' => 'business_mail',
- 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 "user_name" 4 times. Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- 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 "vtiger_ossemployeescf" 3 times. Open
public $customFieldTable = ['vtiger_ossemployeescf', 'ossemployeesid'];
- 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 "vtiger_crmentity.deleted" 3 times. Open
->where(['vtiger_crmentity.deleted' => 0, 'vtiger_ossemployees.ossemployeesid' => $id])->scalar();
- 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.
Call to method __construct
from undeclared class \yii\db\Expression
Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$dataReader = (new App\Db\Query())
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- Exclude checks
Call to undeclared method \App\Db::quoteValue
Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Entering getEmployeeHierarchy(' . $id . ') method ...');
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$data = (new App\Db\Query())
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->update('vtiger_field', ['summaryfield' => 1], ['and', ['tabid' => $tabId],
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$parentId = (new App\Db\Query())
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Exiting getEmployeeHierarchy method ...');
- Exclude checks
Call to undeclared method \App\Db::quoteValue
Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- Exclude checks
Argument 1 (moduleNames)
is array{0:'OSSEmployees'}
but \ModComments::addWidgetTo()
takes string
defined at /code/modules/ModComments/ModComments.php:72
Open
ModComments::addWidgetTo(['OSSEmployees']);
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ('name' == $colName) {
if ($employeesId != $id) {
if ($hasRecordViewAccess) {
$data = '<a href="index.php?module=OSSEmployees&view=Detail&record=' . $employeesId . '">' . $data . '</a>';
} else {
- 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 106.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$dataReader = (new App\Db\Query())
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
->from('vtiger_ossemployees')
->innerJoin('vtiger_crmentity', 'vtiger_ossemployees.ossemployeesid = vtiger_crmentity.crmid')
->leftJoin('vtiger_groups', 'vtiger_crmentity.smownerid = vtiger_groups.groupid')
- 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 102.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$data = (new App\Db\Query())
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
->from('vtiger_ossemployees')
->innerJoin('vtiger_crmentity', 'vtiger_ossemployees.ossemployeesid = vtiger_crmentity.crmid')
->leftJoin('vtiger_groups', 'vtiger_crmentity.smownerid = vtiger_groups.groupid')
- 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 102.
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
Avoid excessively long variable names like $def_detailview_recname. Keep variable name length under 20. Open
public $def_detailview_recname = 'last_name';
- Read upRead up
- Exclude checks
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
Avoid excessively long variable names like $modcommentsModuleInstance. Keep variable name length under 20. Open
$modcommentsModuleInstance = vtlib\Module::getInstance('ModComments');
- Read upRead up
- Exclude checks
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 OSSEmployees extends Vtiger_CRMEntity
- 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 10 and the first side effect is on line 8. Open
<?php
- Exclude checks
The property $table_index is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $tab_name is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $special_functions is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
public function getEmployeeHierarchy($id)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The property $def_detailview_recname is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
public function __getChildEmployees($id, &$childAccounts, $depth)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The property $table_name is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $search_fields_name is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $column_fields is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $def_basicsearch_col is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $tab_name_index is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $search_fields is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $mandatory_fields is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $default_sort_order is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $list_fields_name is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $popup_fields is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
public function __getParentEmployees($id, &$parentAccounts, &$encounteredAccounts)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The property $default_order_by is not named in camelCase. Open
class OSSEmployees extends Vtiger_CRMEntity
{
public $table_name = 'vtiger_ossemployees';
public $table_index = 'ossemployeesid';
public $column_fields = [];
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
public $customFieldTable = ['vtiger_ossemployeescf', 'ossemployeesid'];
- 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
'vtiger_entity_stats' => 'crmid', ];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Format: Field Label => fieldname
- 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 $search_fields_name = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $default_order_by = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $default_sort_order = 'ASC';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$listViewEntries = [];
- 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 (!$hasRecordViewAccess && 'name' != $colName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('name' == $colName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = '<a href="index.php?module=OSSEmployees&view=Detail&record=' . $employeesId . '">' . $data . '</a>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $table_index = 'ossemployeesid';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FL_POSITION' => ['crmentity', 'position'],
- 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 $special_functions = ['set_import_assigned_user'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getEmployeeHierarchy($id)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$listViewHeader = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->list_fields_name as $fieldName => $colName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($hasRecordViewAccess) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = '<b>' . $data . '</b>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $tab_name_index = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Assigned To' => 'assigned_user_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_NAME' => ['ossemployees', 'name'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* returns Employees hierarchy in array format
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$encounteredAccounts = [$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
'vtiger_crmentity' => 'crmid',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_BUSINESSPHONE' => 'business_phone',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_BUSINESSPHONE' => ['ossemployees', 'business_phone'],
- 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 ($employeesId != $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
public $list_fields_name = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_LASTNAME' => 'last_name',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FL_POSITION' => 'position',
- 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
\App\Log::trace('Entering getEmployeeHierarchy(' . $id . ') method ...');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$hasRecordViewAccess = \App\Privilege::isPermitted('OSSEmployees', 'DetailView', $employeesId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vtiger_ossemployees' => 'ossemployeesid',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// For Alphabetical search
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Used when enabling/disabling the mandatory fields for the module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $id - employeeid
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Indicator if this is a custom module or standard module */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Assigned To' => ['crmentity', 'smownerid'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Column value to use on detail view record text display
- 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 (\App\Field::getFieldPermission('OSSEmployees', $colName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Mandatory table for supporting custom fields.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string[] List of fields in the RelationListView
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_LASTNAME' => ['ossemployees', 'last_name'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Callback function list during Importing
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowsList = $this->__getParentEmployees($id, $rowsList, $encounteredAccounts);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $IsCustomModule = true;
- 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 $search_fields = [
- 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
$rowsList = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowsList = $this->__getChildEmployees($id, $rowsList, $rowsList[$id]['depth']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->list_fields_name as $fieldName => $colName) {
- 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
* Mandatory for Saving, Include tables related to this module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_NAME' => 'name',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_BUSINESSMAIL' => 'business_mail',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$accountInfoData[] = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $column_fields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Mandatory for Saving, Include tablename and tablekey columnname here.
- 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
// For Popup listview and UI type support
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $popup_fields = ['last_name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Refers to vtiger_field.fieldname values.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $mandatory_fields = ['createdtime', 'modifiedtime', 'assigned_user_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $accountDepth . $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('parentid' == $colName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $table_name = 'vtiger_ossemployees';
- 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
foreach ($rowsList as $employeesId => $accountInfo) {
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
$data = '<a href="index.php?module=OSSEmployees&view=Detail&record=' . $employeesId . '">' . $data . '</a>';
- 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
public $tab_name = ['vtiger_crmentity', 'vtiger_ossemployees', 'vtiger_ossemployeescf', 'vtiger_entity_stats'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $relationFields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// For Popup window record selection
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $def_detailview_recname = 'last_name';
- 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
'LBL_BUSINESSMAIL' => ['ossemployees', 'business_mail'],
- 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
* Function to get Employees hierarchy of the given Employees.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (\App\Field::getFieldPermission('OSSEmployees', $colName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $def_basicsearch_col = 'last_name';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$listViewHeader[] = \App\Language::translate($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$accountInfoData = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vtiger_ossemployeescf' => 'ossemployeesid',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = \App\Purifier::encodeHtml($accountInfo[$colName]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = '<i>' . $data . '</i>';
- 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
$accountDepth = str_repeat(' .. ', $accountInfo['depth']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- 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
$tabId = \App\Module::getModuleId($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($modcommentsModuleInstance && file_exists('modules/ModComments/ModComments.php')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_crmentity', 'vtiger_ossemployees.ossemployeesid = vtiger_crmentity.crmid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$childAccountInfo = [];
- 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
$hierarchy = ['header' => $listViewHeader, 'entries' => $listViewEntries];
- 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
->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$depth = $parentAccounts[$immediateParentId]['depth'] + 1;
- 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
->innerJoin('vtiger_crmentity', 'vtiger_ossemployees.ossemployeesid = vtiger_crmentity.crmid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$depth;
- 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
$listViewEntries[$employeesId] = $accountInfoData;
- 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
$userNameSql = App\Module::getSqlForNameInDisplayFormat('Users');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$depth = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- 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
\App\Log::trace('Exiting getEmployeeHierarchy method ...');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $hierarchy;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__getParentEmployees($parentId, $parentAccounts, $encounteredAccounts);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_crmentity', 'vtiger_ossemployees.ossemployeesid = vtiger_crmentity.crmid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$immediateParentId = $data['parentid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->list_fields_name as $columnName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_ossemployees')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('vtiger_users', 'vtiger_crmentity.smownerid = vtiger_users.id')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//block with fields in summary
- 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
$parentId = (new App\Db\Query())
- Exclude checks
Line exceeds 120 characters; contains 230 characters Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('vtiger_groups', 'vtiger_crmentity.smownerid = vtiger_groups.groupid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentAccountInfo = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('assigned_user_id' == $columnName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['vtiger_crmentity.deleted' => 0, 'vtiger_ossemployees.parentid' => $id])->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modcommentsModuleInstance = vtlib\Module::getInstance('ModComments');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
include_once 'modules/ModComments/ModComments.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_ossemployees')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('vtiger_groups', 'vtiger_crmentity.smownerid = vtiger_groups.groupid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('module.postinstall' == $eventType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->createCommand()->update('vtiger_field', ['summaryfield' => 1], ['and', ['tabid' => $tabId],
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
\App\Db::getInstance()->createCommand()->update('vtiger_field', ['summaryfield' => 1], ['and', ['tabid' => $tabId],
- Exclude checks
Line exceeds 120 characters; contains 180 characters Open
['columnname' => ['ossemployees_no', 'employee_status', 'name', 'last_name', 'pesel', 'id_card', 'employee_education', 'parentid', 'business_mail']], ])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$accountInfoData[] = $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['parentid'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$encounteredAccounts[] = $parentId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 230 characters Open
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- 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 moduleHandler($moduleName, $eventType)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = Vtiger_Module_Model::getInstance('OSSEmployees')->getFieldByName($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_ossemployees')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentAccountInfo['depth'] = $depth;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userNameSql = App\Module::getSqlForNameInDisplayFormat('Users');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__getChildEmployees($childAccId, $childAccounts, $depth);
- 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
$data = $fieldModel->getDisplayValue($data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$childAccId = $row['ossemployeesid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$childAccountInfo[$columnName] = $row['user_name'];
- 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
// block with comments
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['vtiger_crmentity.deleted' => 0, 'vtiger_ossemployees.ossemployeesid' => $id])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($parentAccounts[$immediateParentId])) {
- 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 (\array_key_exists($childAccId, $childAccounts)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->list_fields_name as $columnName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$childAccountInfo[$columnName] = $row[$columnName];
- 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
$childAccounts[$childAccId] = $childAccountInfo;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentAccountInfo[$columnName] = $data['user_name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentAccountInfo[$columnName] = $data[$columnName];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentAccounts[$id] = $parentAccountInfo;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$childAccountInfo['depth'] = $depth;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $childAccounts;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __getParentEmployees($id, &$parentAccounts, &$encounteredAccounts)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($parentId) && !\in_array($parentId, $encounteredAccounts)) {
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $parentAccounts;
- 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
$dataReader = (new App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($dataReader->count() > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('assigned_user_id' == $columnName) {
- 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
$data = (new App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('vtiger_users', 'vtiger_crmentity.smownerid = vtiger_users.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
['columnname' => ['ossemployees_no', 'employee_status', 'name', 'last_name', 'pesel', 'id_card', 'employee_education', 'parentid', 'business_mail']], ])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
ModComments::addWidgetTo(['OSSEmployees']);
- 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
->where(['vtiger_crmentity.deleted' => 0, 'vtiger_ossemployees.ossemployeesid' => $id])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __getChildEmployees($id, &$childAccounts, $depth)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (class_exists('ModComments')) {
- Exclude checks
The method __getChildEmployees is not named in camelCase. Open
public function __getChildEmployees($id, &$childAccounts, $depth)
{
$userNameSql = App\Module::getSqlForNameInDisplayFormat('Users');
$dataReader = (new App\Db\Query())
->select(['vtiger_ossemployees.*', 'user_name' => new \yii\db\Expression('CASE when (vtiger_users.user_name not like ' . App\Db::getInstance()->quoteValue('') . ") THEN $userNameSql ELSE vtiger_groups.groupname END")])
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method __getParentEmployees is not named in camelCase. Open
public function __getParentEmployees($id, &$parentAccounts, &$encounteredAccounts)
{
$parentId = (new App\Db\Query())
->select(['parentid'])
->from('vtiger_ossemployees')
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}