YetiForceCompany/YetiForceCRM

View on GitHub
modules/Import/models/ListView.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

        $queryGenerator = new \App\QueryGenerator($moduleModel->get('name'));
Severity: Minor
Found in modules/Import/models/ListView.php by phpmd

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 getListViewEntries uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $pagingModel->set('nextPageExists', false);
        }
Severity: Minor
Found in modules/Import/models/ListView.php by phpmd

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 'addLastImportedRecordConditions'.
Open

        $user = \App\User::getCurrentUserId();
Severity: Minor
Found in modules/Import/models/ListView.php by phpmd

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_Loader' in method 'getInstance'.
Open

        $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', 'Import');
Severity: Minor
Found in modules/Import/models/ListView.php by phpmd

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 'Import_Module_Model' in method 'addLastImportedRecordConditions'.
Open

        $userDBTableName = Import_Module_Model::getDbTableName($user);
Severity: Minor
Found in modules/Import/models/ListView.php by phpmd

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_Module_Model' in method 'getInstance'.
Open

        $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
Severity: Minor
Found in modules/Import/models/ListView.php by phpmd

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 unused parameters such as '$linkParams'.
Open

    public function getListViewMassActions($linkParams)
Severity: Minor
Found in modules/Import/models/ListView.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$viewId'.
Open

    public static function getInstance($moduleName, $viewId = '0')
Severity: Minor
Found in modules/Import/models/ListView.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$linkParams'.
Open

    public function getListViewLinks($linkParams)
Severity: Minor
Found in modules/Import/models/ListView.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Saw unextractable annotation for comment '* @param <array> $linkParams'</array>
Open

     * @param <Array> $linkParams
Severity: Info
Found in modules/Import/models/ListView.php by phan

Default value for int $viewId can't be string
Open

    public static function getInstance($moduleName, $viewId = '0')
Severity: Minor
Found in modules/Import/models/ListView.php by phan

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

        $queryGenerator->initForDefaultCustomView(true);
Severity: Critical
Found in modules/Import/models/ListView.php by phan

Call to undeclared method \App\Db\Query::innerJoin
Open

        $query->innerJoin($userDBTableName, $moduleModel->basetable . '.' . $moduleModel->basetableid . " = $userDBTableName.recordid");
Severity: Critical
Found in modules/Import/models/ListView.php by phan

Suspicious type false of a variable or expression used to build a string. (Expected type to be able to cast to a string)
Open

        $query->innerJoin($userDBTableName, $moduleModel->basetable . '.' . $moduleModel->basetableid . " = $userDBTableName.recordid");
Severity: Minor
Found in modules/Import/models/ListView.php by phan

Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

        $user = \App\User::getCurrentUserId();
Severity: Critical
Found in modules/Import/models/ListView.php by phan

Declaration of function getListViewMassActions(array $linkParams) : false should be compatible with function getListViewMassActions(array $linkParams) : \Vtiger_Link_Model[] defined in /code/modules/Vtiger/models/ListView.php:236
Open

    public function getListViewMassActions($linkParams)
Severity: Minor
Found in modules/Import/models/ListView.php by phan

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

        $query = $this->getQueryGenerator()->createQuery();
Severity: Critical
Found in modules/Import/models/ListView.php by phan

Call to undeclared method \App\Db\Query::where
Open

        $query->where(['and', ['not', [$userDBTableName . '.temp_status' => [Import_Data_Action::IMPORT_RECORD_FAILED, Import_Data_Action::IMPORT_RECORD_SKIPPED]]], ['not', [$userDBTableName . '.recordid' => null]]]);
Severity: Critical
Found in modules/Import/models/ListView.php by phan

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

        $queryGenerator = new \App\QueryGenerator($moduleModel->get('name'));
Severity: Critical
Found in modules/Import/models/ListView.php by phan

Call to undeclared method \App\Db\Query::count
Open

        return $query->count();
Severity: Critical
Found in modules/Import/models/ListView.php by phan

Saw unextractable annotation for comment '* @param <array> $linkParams'</array>
Open

     * @param <Array> $linkParams
Severity: Info
Found in modules/Import/models/ListView.php by phan

Call to undeclared method \App\Db\Query::all
Open

        $rows = $query->all();
Severity: Critical
Found in modules/Import/models/ListView.php by phan

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

        $query = $this->getQueryGenerator()->createQuery();
Severity: Critical
Found in modules/Import/models/ListView.php by phan

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Import_ListView_Model extends Vtiger_ListView_Model

The class Import_ListView_Model is not named in CamelCase.
Open

class Import_ListView_Model extends Vtiger_ListView_Model
{
    /**
     * Function to get the list of listview links for the module.
     *
Severity: Minor
Found in modules/Import/models/ListView.php by phpmd

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

        $this->loadListViewOrderBy();

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

        if (0 !== $pagingModel->get('limit')) {

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

        }

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

        foreach ($rows as $row) {

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

    {

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

     * @return int

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

     * @param string $moduleName - Module Name

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

    {

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

        return false;

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

    {

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

    }

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

     * @return Vtiger_ListView_Model instance

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

    public function getListViewMassActions($linkParams)

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

    }

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

        $pageLimit = $pagingModel->getPageLimit();

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

            $query->limit($pageLimit + 1)->offset($pagingModel->getStartIndex());

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

        $query = $this->addLastImportedRecordConditions($query);

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

    }

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

     * @param <Array> $linkParams

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

    /**

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

        $this->loadListViewCondition();

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

        return $query->count();

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

        return false;

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

    public static function getInstance($moduleName, $viewId = '0')

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

    }

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

     *

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

     *

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

     * Static Function to get the Instance of Vtiger ListView model for a given module and custom view.

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

        $user = \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

     * @return array - Associative array of record id mapped to Vtiger_Record_Model instance

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

        $moduleModel = $this->getModule();

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

     *

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

        $moduleModel = Vtiger_Module_Model::getInstance($moduleName);

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

    public function addLastImportedRecordConditions($query)

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

    {

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

        return $query;

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

     * Function to get the list view entries.

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

     */

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

            $pagingModel->set('nextPageExists', false);

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

        $listViewRecordModels = [];

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

            $listViewRecordModels[$row['id']] = $moduleModel->getRecordFromArray($row);

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

        }

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

    public function getListViewCount()

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

     * @return false - no List View Links needed on Import pages

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

    /**

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

        $count = \count($rows);

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

     * ListView count.

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

     *

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

        $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', 'Import');

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

        $instance = new $modelClassName();

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

    /**

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

     *

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

     */

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

     * @param <Array> $linkParams

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

        $query = $this->getQueryGenerator()->createQuery();

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

    /**

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

     * Function adds conditions to query.

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

     *

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

     */

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

    public function getListViewEntries(Vtiger_Paging_Model $pagingModel)

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

        $pagingModel->calculatePageRange($count);

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

            array_pop($rows);

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

            $pagingModel->set('nextPageExists', true);

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

    /**

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

     */

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

     */

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

     * @param \App\Db\Query $query

Line exceeds 120 characters; contains 136 characters
Open

        $query->innerJoin($userDBTableName, $moduleModel->basetable . '.' . $moduleModel->basetableid . " = $userDBTableName.recordid");

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

        $query->innerJoin($userDBTableName, $moduleModel->basetable . '.' . $moduleModel->basetableid . " = $userDBTableName.recordid");

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

    /**

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

     * Function to get the list of Mass actions for the module.

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

     * @param Vtiger_Paging_Model $pagingModel

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 ($count > $pageLimit) {

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

        return $listViewRecordModels;

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

        $this->loadListViewCondition();

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

        $query->where(['and', ['not', [$userDBTableName . '.temp_status' => [Import_Data_Action::IMPORT_RECORD_FAILED, Import_Data_Action::IMPORT_RECORD_SKIPPED]]], ['not', [$userDBTableName . '.recordid' => null]]]);

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

    }

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

     * Function to get the list of listview links for the module.

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

     * @return false - no List View Links needed on Import pages

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

        unset($rows);

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

        $query = $this->getQueryGenerator()->createQuery();

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

     * @param int    $viewId     - Custom View Id

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

     *

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

     *

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

        $moduleModel = $this->getModule();

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

    public function getListViewLinks($linkParams)

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

    {

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

     *

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

     *

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

    {

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

        $rows = $query->all();

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

        $query = $this->addLastImportedRecordConditions($query);

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

        $queryGenerator->initForDefaultCustomView(true);

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

    }

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

     */

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

        $userDBTableName = Import_Module_Model::getDbTableName($user);

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

        $queryGenerator = new \App\QueryGenerator($moduleModel->get('name'));

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

        return $instance->set('module', $moduleModel)->set('query_generator', $queryGenerator);

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

     * @return \App\Db\Query

Line exceeds 120 characters; contains 217 characters
Open

        $query->where(['and', ['not', [$userDBTableName . '.temp_status' => [Import_Data_Action::IMPORT_RECORD_FAILED, Import_Data_Action::IMPORT_RECORD_SKIPPED]]], ['not', [$userDBTableName . '.recordid' => null]]]);

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

class Import_ListView_Model extends Vtiger_ListView_Model

There are no issues that match your filters.

Category
Status