YetiForceCompany/YetiForceCRM

View on GitHub
modules/Import/actions/Lock.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Missing class import via use statement (line '28', column '14').
Open

            throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
Severity: Minor
Found in modules/Import/actions/Lock.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 unLock has a boolean flag argument $module, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function unLock(App\User $user, $module = false)
Severity: Minor
Found in modules/Import/actions/Lock.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Missing class import via use statement (line '81', column '15').
Open

        return (new \App\Db\Query())
Severity: Minor
Found in modules/Import/actions/Lock.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

Avoid using static access to class '\App\Db' in method 'unLock'.
Open

        $db = \App\Db::getInstance();
Severity: Minor
Found in modules/Import/actions/Lock.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 '\App\Module' in method 'lock'.
Open

                'tabid' => \App\Module::getModuleId($module),
Severity: Minor
Found in modules/Import/actions/Lock.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 '\App\Module' in method 'isLockedForModule'.
Open

            ->where(['tabid' => \App\Module::getModuleId($module)])->one();
Severity: Minor
Found in modules/Import/actions/Lock.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 '\App\Module' in method 'unLock'.
Open

            $where['tabid'] = \App\Module::getModuleId($module);
Severity: Minor
Found in modules/Import/actions/Lock.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 'Users_Privileges_Model' in method 'checkPermission'.
Open

        $currentUserPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
Severity: Minor
Found in modules/Import/actions/Lock.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

Define a constant instead of duplicating this literal "vtiger_import_locks" 3 times.
Open

            ->insert('vtiger_import_locks', [
Severity: Critical
Found in modules/Import/actions/Lock.php by sonar-php

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 "tabid" 3 times.
Open

                'tabid' => \App\Module::getModuleId($module),
Severity: Critical
Found in modules/Import/actions/Lock.php by sonar-php

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::createCommand
Open

        \App\Db::getInstance()->createCommand()
Severity: Critical
Found in modules/Import/actions/Lock.php by phan

Parameter $user has undeclared type \App\User (Did you mean class \Tests\App\User)
Open

    public static function lock($importId, $module, App\User $user)
Severity: Minor
Found in modules/Import/actions/Lock.php by phan

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

                'userid' => $user->getId(),
Severity: Critical
Found in modules/Import/actions/Lock.php by phan

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

        return (new \App\Db\Query())
Severity: Critical
Found in modules/Import/actions/Lock.php by phan

Parameter $user has undeclared type \App\User (Did you mean class \Tests\App\User)
Open

    public static function unLock(App\User $user, $module = false)
Severity: Minor
Found in modules/Import/actions/Lock.php by phan

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

        $where = ['userid' => $user->getId()];
Severity: Critical
Found in modules/Import/actions/Lock.php by phan

Argument 1 (mixed) is string but \Users_Privileges_Model::hasModulePermission() takes int defined at /code/modules/Users/models/Privileges.php:101
Open

        if (!$currentUserPrivilegesModel->hasModulePermission($request->getModule())) {
Severity: Minor
Found in modules/Import/actions/Lock.php by phan

Default value for string $module can't be false
Open

    public static function unLock(App\User $user, $module = false)
Severity: Minor
Found in modules/Import/actions/Lock.php by phan

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

        $db->createCommand()->delete('vtiger_import_locks', $where)->execute();
Severity: Critical
Found in modules/Import/actions/Lock.php by phan

Avoid excessively long variable names like $currentUserPrivilegesModel. Keep variable name length under 20.
Open

        $currentUserPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
Severity: Minor
Found in modules/Import/actions/Lock.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

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

class Import_Lock_Action extends \App\Controller\Action

The class Import_Lock_Action is not named in CamelCase.
Open

class Import_Lock_Action extends \App\Controller\Action
{
    /**
     * Constructor.
     */
Severity: Minor
Found in modules/Import/actions/Lock.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

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

        $db = \App\Db::getInstance();
Severity: Minor
Found in modules/Import/actions/Lock.php by phpmd

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

     * Constructor.

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

    /** {@inheritdoc} */

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

     * @param string    $module

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

                'importid' => $importId,

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

    public function __construct()

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

        $db->createCommand()->delete('vtiger_import_locks', $where)->execute();

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

            throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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

                'userid' => $user->getId(),

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

        if (!$currentUserPrivilegesModel->hasModulePermission($request->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

                'tabid' => \App\Module::getModuleId($module),

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

     * @param int       $importId

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(['tabid' => \App\Module::getModuleId($module)])->one();

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

     * Lock.

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

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|bool

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

     * Is locked for module.

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

    public function checkPermission(App\Request $request)

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

    {

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

     * Unlock.

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

     *

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

        $currentUserPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

        \App\Db::getInstance()->createCommand()

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

            ])->execute();

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

        $where = ['userid' => $user->getId()];

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 false;

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

     * @param \App\User $user

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

    /** {@inheritdoc} */

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 static function lock($importId, $module, App\User $user)

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

            ->insert('vtiger_import_locks', [

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

        return (new \App\Db\Query())

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

                'locked_since' => date('Y-m-d H:i:s'),

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 static function unLock(App\User $user, $module = 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

     * @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

    {

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

        if ($module) {

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

    public static function isLockedForModule($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

            $where['tabid'] = \App\Module::getModuleId($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

            ->from('vtiger_import_locks')

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

class Import_Lock_Action extends \App\Controller\Action

There are no issues that match your filters.

Category
Status