YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/CustomView/models/Module.php

Summary

Maintainability
A
0 mins
Test Coverage
D
67%

Missing class import via use statement (line '59', column '77').
Open

        $i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();

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 '23', column '16').
Open

        $query = new App\Db\Query();

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 '107', column '22').
Open

        $dataReader = (new App\Db\Query())

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\CustomView' in method 'upadteSequences'.
Open

            \App\CustomView::clearCacheById($cvId);

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\Db' in method 'upadteSequences'.
Open

        $db = App\Db::getInstance();

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 "&cvid=" 4 times.
Open

        return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=default&sourceModule=' . $module . '&cvid=' . $cvid . '&isDefault=' . $isDefault;

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 undeclared method \App\Db\Query::select
Open

        $dataReader = (new App\Db\Query())

Call to undeclared method \App\Db::createCommand
Open

        $i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();

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

            $query->select(['user'])

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

            $query->select(['member'])

Call to method close from undeclared class \yii\db\DataReader
Open

        $dataReader->close();

Call to undeclared method \App\Db::quoteColumnName
Open

            $caseSequence .= ' WHEN ' . $db->quoteColumnName('cvid') . ' = ' . $db->quoteValue($cvId) . ' THEN ' . $db->quoteValue($sequence);

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

            $query->select(['userid'])

Call to undeclared method \App\Db::quoteValue
Open

            $caseSequence .= ' WHEN ' . $db->quoteColumnName('cvid') . ' = ' . $db->quoteValue($cvId) . ' THEN ' . $db->quoteValue($sequence);

Call to method __construct from undeclared class \yii\db\Expression
Open

        $i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();

Call to method readColumn from undeclared class \yii\db\DataReader
Open

        while ($user = $dataReader->readColumn(0)) {

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

class Settings_CustomView_Module_Model extends Settings_Vtiger_Module_Model

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = App\Db::getInstance();

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 class Settings_CustomView_Module_Model is not named in CamelCase.
Open

class Settings_CustomView_Module_Model extends Settings_Vtiger_Module_Model
{
    /**
     * Gets members filter by type.
     *

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Avoid variables with short names like $i. Configured minimum length is 3.
Open

        $i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();

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

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

     * Gets members filter by type.

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

     * @param int    $cvId

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

     *

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

        $dataReader->close();

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

    public function getFilterPermissionsView(int $cvId, string $action): array

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

                ->from('u_#__cv_privileges')

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

        foreach ($params as $sequence => $cvId) {

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

        $users = [];

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

        }

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

        $dataReader = $query->createCommand()->query();

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

        $db = App\Db::getInstance();

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

     *

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

        } elseif ('permissions' == $action) {

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

        $caseSequence = 'CASE ';

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

     * @return array

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 string $action

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

        $query = new App\Db\Query();

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

            $query->select(['userid'])

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

                ->orderBy(['user' => SORT_ASC]);

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

                ->where(['cvid' => $cvId])

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

        return $users;

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

            $query->select(['user'])

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

            $caseSequence .= ' WHEN ' . $db->quoteColumnName('cvid') . ' = ' . $db->quoteValue($cvId) . ' THEN ' . $db->quoteValue($sequence);

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

        while ($user = $dataReader->readColumn(0)) {

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

                ->from('u_#__featured_filter')

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

            $query->select(['member'])

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

                ->from('vtiger_user_module_preferences')

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

        if ('default' == $action) {

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

        } elseif ('featured' == $action) {

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

                ->where(['cvid' => $cvId])

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

            $users[$members[0]][] = $user;

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

                ->orderBy(['userid' => SORT_ASC]);

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

                ->orderBy(['member' => SORT_ASC]);

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

     */

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

                ->where(['default_cvid' => $cvId])

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

    public static function upadteSequences($params)

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

            $members = explode(':', $user);

Line exceeds 120 characters; contains 149 characters
Open

        $i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();

Line exceeds 120 characters; contains 169 characters
Open

        return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=default&sourceModule=' . $module . '&cvid=' . $cvid . '&isDefault=' . $isDefault;

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

            \App\CustomView::clearCacheById($cvId);

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

        return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=permissions&sourceModule=' . $module . '&cvid=' . $cvid;

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

        $dataReader = (new App\Db\Query())

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

        return $i;

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

        return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=featured&sourceModule=' . $module . '&cvid=' . $cvid;

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

        return 'index.php?module=CustomView&view=EditAjax&source_module=' . $module;

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

        $modulesList = [];

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

    public function getUrlDefaultUsers($module, $cvid, $isDefault)

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

            ->leftJoin('vtiger_tab', 'vtiger_tab.name = vtiger_customview.entitytype')

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

    {

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

            ->where(['vtiger_tab.presence' => 0])

Line exceeds 120 characters; contains 141 characters
Open

        return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=featured&sourceModule=' . $module . '&cvid=' . $cvid;

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

        $i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();

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

        foreach ($params as $cvId) {

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

    {

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

    /**

Line exceeds 120 characters; contains 142 characters
Open

            $caseSequence .= ' WHEN ' . $db->quoteColumnName('cvid') . ' = ' . $db->quoteValue($cvId) . ' THEN ' . $db->quoteValue($sequence);

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 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=default&sourceModule=' . $module . '&cvid=' . $cvid . '&isDefault=' . $isDefault;

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

     * Gets URL for modal window with permission settings.

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

     * @return string

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

    public function getUrlToEdit($module, $record)

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

            ->select(['vtiger_tab.tabid', 'vtiger_customview.entitytype'])

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

        $caseSequence .= ' END';

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

    }

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

            $modulesList[$row['tabid']] = $row['entitytype'];

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

        return 'index.php?module=CustomView&parent=Settings&view=SortOrderModal&type=featured&sourceModule=' . $module . '&cvid=' . $cvid;

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

        while ($row = $dataReader->read()) {

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

    {

Line exceeds 120 characters; contains 138 characters
Open

        return 'index.php?module=CustomView&parent=Settings&view=SortOrderModal&type=featured&sourceModule=' . $module . '&cvid=' . $cvid;

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

    {

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

            ->from('vtiger_customview')

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

        $dataReader->close();

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

        return $modulesList;

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 string $module

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 "index.php?module=CustomView&view=EditAjax&source_module=$module&record=$record";

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

    public function getCreateFilterUrl($module)

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

    public function getSortingFilterUrl($module, $cvid)

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

     * @param int    $cvid

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

    public function getPrivilegesUrl(string $module, int $cvid): string

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 getFeaturedFilterUrl($module, $cvid)

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

    }

Line exceeds 120 characters; contains 144 characters
Open

        return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=permissions&sourceModule=' . $module . '&cvid=' . $cvid;

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

    public static function getSupportedModules()

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

            ->createCommand()->query();

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

class Settings_CustomView_Module_Model extends Settings_Vtiger_Module_Model

There are no issues that match your filters.

Category
Status