Missing class import via use statement (line '36', column '25'). Open
$queryGenerator = new App\QueryGenerator('Assets');
- 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 '40', column '21'). Open
$subQuery = (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => App\User::getCurrentUserId()])->distinct('crmid');
- 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 getData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$query->andWhere(['vtiger_crmentity.smownerid' => App\User::getCurrentUserId()]);
}
- 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 'Users_Record_Model' in method 'process'. Open
$currentUser = Users_Record_Model::getCurrentUserModel();
- 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_Widget_Model' in method 'process'. Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUser->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
The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$viewer->view('dashboards/ExpiringSoldProducts.tpl', $moduleName);
}
- 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\User' in method 'getData'. Open
$query->andWhere(['vtiger_crmentity.smownerid' => 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\User' in method 'getData'. Open
$subQuery = (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => App\User::getCurrentUserId()])->distinct('crmid');
- 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
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('RELATED_MODULE', 'Assets');
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('DATA', self::getData($request, $widget));
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('CURRENTUSER', $currentUser);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('MODULE_NAME', $moduleName);
- Exclude checks
Call to method __construct
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = new App\QueryGenerator('Assets');
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setFields($fields);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$subQuery = (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => App\User::getCurrentUserId()])->distinct('crmid');
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$subQuery = (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => App\User::getCurrentUserId()])->distinct('crmid');
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('WIDGET', $widget);
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$query->andWhere(['vtiger_crmentity.smownerid' => App\User::getCurrentUserId()]);
- Exclude checks
Call to method createQuery
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$query = $queryGenerator->createQuery();
- Exclude checks
Call to method getInstance
from undeclared class \Vtiger_Widget_Model
Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUser->getId());
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Assets_ExpiringSoldProducts_Dashboard extends Vtiger_IndexAjax_View
- Exclude checks
The class Assets_ExpiringSoldProducts_Dashboard is not named in CamelCase. Open
class Assets_ExpiringSoldProducts_Dashboard extends Vtiger_IndexAjax_View
{
/** {@inheritdoc} */
public function process(App\Request $request)
{
- 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUser->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('CURRENTUSER', $currentUser);
- 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
$viewer->assign('RELATED_MODULE', 'Assets');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer = $this->getViewer($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('WIDGET', $widget);
- 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
$queryGenerator->setFields($fields);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['vtiger_crmentity.smownerid' => App\User::getCurrentUserId()]);
- 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
$query->limit($limit);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('MODULE_NAME', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Include special script and css needed for this widget
- 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
$query = $queryGenerator->createQuery();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentUser = Users_Record_Model::getCurrentUserModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = new App\QueryGenerator('Assets');
- 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
$limit = 10;
- 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
$moduleName = $request->getModule();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('dashboards/ExpiringSoldProductsContents.tpl', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getData(App\Request $request, $widget)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($widget->get('limit'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$subQuery = (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => App\User::getCurrentUserId()])->distinct('crmid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['in', 'vtiger_crmentity.smownerid', $subQuery]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('dashboards/ExpiringSoldProducts.tpl', $moduleName);
- 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 = ['id', 'assetname', 'dateinservice', 'parent_id'];
- Exclude checks
Line exceeds 120 characters; contains 168 characters Open
$subQuery = (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => App\User::getCurrentUserId()])->distinct('crmid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->orderBy('vtiger_assets.dateinservice');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $query->all();
- 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 ($request->has('content')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('DATA', self::getData($request, $widget));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$limit = $widget->get('limit');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('common' === $request->getByType('showtype')) {
- Exclude checks
Class name "Assets_ExpiringSoldProducts_Dashboard" is not in camel caps format Open
class Assets_ExpiringSoldProducts_Dashboard extends Vtiger_IndexAjax_View
- Exclude checks