Missing class import via use statement (line '67', column '15'). Open
return (new \App\Db\Query())->select(['rolename'])->from('vtiger_role')->innerJoin('vtiger_user2role', 'vtiger_role.roleid = vtiger_user2role.roleid')->where(['vtiger_user2role.userid' => $userId])->scalar();
- 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 '\App\Language' in method 'process'. Open
$html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('Role', 'Users') . '</th>';
- 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 'process'. Open
$html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('OSSTimeControl', 'OSSTimeControl') . '</th>';
- 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_Record_Model' in method 'getUserList'. Open
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $this->textParser->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\Fields\RangeTime' in method 'process'. Open
$html .= "<td style=\"{$bodyStyle} text-align:center;\">" . \App\Fields\RangeTime::displayElapseTime($data['time']) . '</td>';
- 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 'process'. Open
$html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('User Name', 'Users') . '</th>';
- 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 'getUserList'. Open
'role' => \App\Language::translate($this->getRoleName($recordModel->get('assigned_user_id')), $this->textParser->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
Define a constant instead of duplicating this literal "" 3 times. Open
$html .= "<td style=\"{$bodyStyle}\">" . $user . '</td>';
- 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 "" 3 times. Open
$html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('User Name', 'Users') . '</th>';
- 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 instance property moduleName
from undeclared class \App\TextParser
Open
'role' => \App\Language::translate($this->getRoleName($recordModel->get('assigned_user_id')), $this->textParser->moduleName),
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
return (new \App\Db\Query())->select(['rolename'])->from('vtiger_role')->innerJoin('vtiger_user2role', 'vtiger_role.roleid = vtiger_user2role.roleid')->where(['vtiger_user2role.userid' => $userId])->scalar();
- Exclude checks
Reference to instance property moduleName
from undeclared class \App\TextParser
Open
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $this->textParser->moduleName);
- Exclude checks
Call to method getParam
from undeclared class \App\TextParser
(Did you mean class \Tests\App\TextParser) Open
$ids = $this->textParser->getParam('pdf')->getVariable('recordsId');
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class OSSTimeControl_UserGroup_Textparser extends \App\TextParser\Base
- Exclude checks
The class OSSTimeControl_UserGroup_Textparser is not named in CamelCase. Open
class OSSTimeControl_UserGroup_Textparser extends \App\TextParser\Base
{
/** @var string Class name */
public $name = 'LBL_TIME_CONTROL_USER_GROUP';
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
/** @var mixed Parser type */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $html . '</tbody></table>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- 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
$bodyStyle = 'font-size:8px;border:1px solid #ddd;padding:0px4px;';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= "<td style=\"{$bodyStyle}\">" . $user . '</td>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= "<td style=\"{$bodyStyle} text-align:center;\">" . $data['role'] . '</td>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$users = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\is_array($ids)) {
- 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
protected function getUserList()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= '<tr>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= '</tr>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Process.
- 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
$html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('User Name', 'Users') . '</th>';
- 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
$ids = $this->textParser->getParam('pdf')->getVariable('recordsId');
- 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
$user = $recordModel->getDisplayValue('assigned_user_id', $recordId, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$users[$user] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= '<table class="table" style="border-collapse:collapse;width:100%;"><thead><tr>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('Role', 'Users') . '</th>';
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
$html .= "<td style=\"{$bodyStyle} text-align:center;\">" . \App\Fields\RangeTime::displayElapseTime($data['time']) . '</td>';
- 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
$html .= "<td style=\"{$bodyStyle} text-align:center;\">" . \App\Fields\RangeTime::displayElapseTime($data['time']) . '</td>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$recordModel->isViewable()) {
- 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
$html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('OSSTimeControl', 'OSSTimeControl') . '</th>';
- 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
$ids = [$ids];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getRoleName($userId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 216 characters Open
return (new \App\Db\Query())->select(['rolename'])->from('vtiger_role')->innerJoin('vtiger_user2role', 'vtiger_role.roleid = vtiger_user2role.roleid')->where(['vtiger_user2role.userid' => $userId])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= '</tr></thead><tbody>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $name = 'LBL_TIME_CONTROL_USER_GROUP';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$headerStyle = 'font-size:9px;padding:0px 4px;text-align:center;';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $type = 'pdf';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'role' => \App\Language::translate($this->getRoleName($recordModel->get('assigned_user_id')), $this->textParser->moduleName),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($ids as $recordId) {
- 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
/** @var string Class name */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'time' => $time,
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
'role' => \App\Language::translate($this->getRoleName($recordModel->get('assigned_user_id')), $this->textParser->moduleName),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('OSSTimeControl', 'OSSTimeControl') . '</th>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $this->textParser->moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$time = ($users[$user]['time'] ?? 0) + $recordModel->get('sum_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
foreach ($this->getUserList() as $user => $data) {
- 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 $users;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new \App\Db\Query())->select(['rolename'])->from('vtiger_role')->innerJoin('vtiger_user2role', 'vtiger_role.roleid = vtiger_user2role.roleid')->where(['vtiger_user2role.userid' => $userId])->scalar();
- Exclude checks
Class name "OSSTimeControl_UserGroup_Textparser" is not in camel caps format Open
class OSSTimeControl_UserGroup_Textparser extends \App\TextParser\Base
- Exclude checks