YetiForceCompany/YetiForceCRM

View on GitHub
modules/Assets/dashboards/ExpiringSoldProducts.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Missing class import via use statement (line '36', column '25').
Open

        $queryGenerator = new App\QueryGenerator('Assets');

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

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()]);
        }

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

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

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);
        }

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

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

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

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('DATA', self::getData($request, $widget));

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('CURRENTUSER', $currentUser);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('MODULE_NAME', $moduleName);

Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $queryGenerator = new App\QueryGenerator('Assets');

Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $queryGenerator->setFields($fields);

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

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

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('WIDGET', $widget);

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

Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $query = $queryGenerator->createQuery();

Call to method getInstance from undeclared class \Vtiger_Widget_Model
Open

        $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUser->getId());

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

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)
    {

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

    {

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

        $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUser->getId());

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

        $viewer->assign('CURRENTUSER', $currentUser);

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

    }

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

        $viewer->assign('RELATED_MODULE', 'Assets');

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

        $viewer = $this->getViewer($request);

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

        $viewer->assign('WIDGET', $widget);

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

    {

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

        $queryGenerator->setFields($fields);

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

            $query->andWhere(['vtiger_crmentity.smownerid' => App\User::getCurrentUserId()]);

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

        }

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

        $query->limit($limit);

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

    /** {@inheritdoc} */

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

        $viewer->assign('MODULE_NAME', $moduleName);

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

        //Include special script and css needed for this widget

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

        }

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

        $query = $queryGenerator->createQuery();

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

    public function process(App\Request $request)

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

        $currentUser = Users_Record_Model::getCurrentUserModel();

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

        $queryGenerator = new App\QueryGenerator('Assets');

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

        } else {

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

        $limit = 10;

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

        } else {

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

        $moduleName = $request->getModule();

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

            $viewer->view('dashboards/ExpiringSoldProductsContents.tpl', $moduleName);

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

    public static function getData(App\Request $request, $widget)

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

        if (!empty($widget->get('limit'))) {

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

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

            $query->andWhere(['in', 'vtiger_crmentity.smownerid', $subQuery]);

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

            $viewer->view('dashboards/ExpiringSoldProducts.tpl', $moduleName);

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

        }

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

        $fields = ['id', 'assetname', 'dateinservice', 'parent_id'];

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

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

        $query->orderBy('vtiger_assets.dateinservice');

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

        return $query->all();

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

    }

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

        if ($request->has('content')) {

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

        $viewer->assign('DATA', self::getData($request, $widget));

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

            $limit = $widget->get('limit');

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

        if ('common' === $request->getByType('showtype')) {

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

class Assets_ExpiringSoldProducts_Dashboard extends Vtiger_IndexAjax_View

There are no issues that match your filters.

Category
Status