YetiForceCompany/YetiForceCRM

View on GitHub
api/webservice/Core/Module.php

Summary

Maintainability
A
0 mins
Test Coverage
A
90%

Missing class import via use statement (line '70', column '21').
Open

        $fieldInfo = (new \App\Db\Query())->from('vtiger_field')->where([
Severity: Minor
Found in api/webservice/Core/Module.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\Cache' in method 'getApiFieldPermission'.
Open

        if (\App\Cache::has('API-FieldPermission', $cacheName)) {
Severity: Minor
Found in api/webservice/Core/Module.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\Cache' in method 'getApiFieldPermission'.
Open

            return \App\Cache::get('API-FieldPermission', $cacheName);
Severity: Minor
Found in api/webservice/Core/Module.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 '\Api\WebservicePremium\Privilege' in method 'getPermittedModules'.
Open

            if (\Api\WebservicePremium\Privilege::isPermitted($value['name'])) {
Severity: Minor
Found in api/webservice/Core/Module.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\Language' in method 'getPermittedModules'.
Open

                $modules[$value['name']] = \App\Language::translate($value['name'], $value['name']);
Severity: Minor
Found in api/webservice/Core/Module.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 'getApiFieldPermission'.
Open

            'tabid' => \App\Module::getModuleId($moduleName),
Severity: Minor
Found in api/webservice/Core/Module.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 '\vtlib\Functions' in method 'getPermittedModules'.
Open

        foreach (\vtlib\Functions::getAllModules(false, false, 0) as $value) {
Severity: Minor
Found in api/webservice/Core/Module.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 '\Api\WebservicePremium\Privilege' in method 'checkModuleAccess'.
Open

        return \Api\WebservicePremium\Privilege::isPermitted($moduleName);
Severity: Minor
Found in api/webservice/Core/Module.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\Cache' in method 'getApiFieldPermission'.
Open

        \App\Cache::save('API-FieldPermission', $cacheName, $fieldInfo, \App\Cache::LONG);
Severity: Minor
Found in api/webservice/Core/Module.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 "API-FieldPermission" 3 times.
Open

        if (\App\Cache::has('API-FieldPermission', $cacheName)) {
Severity: Critical
Found in api/webservice/Core/Module.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\Query::from
Open

        $fieldInfo = (new \App\Db\Query())->from('vtiger_field')->where([
Severity: Critical
Found in api/webservice/Core/Module.php by phan

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

     * Check module access.

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

     * @param string $moduleName

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

    public static function getPermittedModules(): 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

    /**

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

            return isset(static::$permittedModules[$moduleName]);

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

    public static function getApiFieldPermission(string $moduleName, int $serverId)

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

    protected static $permittedModules;

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

            return \App\Cache::get('API-FieldPermission', $cacheName);

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

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

     * Returns info about field to permission for record.

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

        $cacheName = $moduleName . $serverId;

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

        $fieldInfo = (new \App\Db\Query())->from('vtiger_field')->where([

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

     * @param string $moduleName

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

    public static function checkModuleAccess($moduleName): 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

            'uitype' => 318,

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

        $modules = [];

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

        foreach (\vtlib\Functions::getAllModules(false, false, 0) as $value) {

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 static::$permittedModules;

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

        return \Api\WebservicePremium\Privilege::isPermitted($moduleName);

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

     * @param int    $serverId

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

     */

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

            'fieldparams' => $serverId

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

        \App\Cache::save('API-FieldPermission', $cacheName, $fieldInfo, \App\Cache::LONG);

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

        return $fieldInfo;

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

        if (isset(static::$permittedModules)) {

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 bool

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

        if (isset(static::$permittedModules)) {

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

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

                $modules[$value['name']] = \App\Language::translate($value['name'], $value['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

        ])->one();

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

            if (\Api\WebservicePremium\Privilege::isPermitted($value['name'])) {

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

    /** @var array Permitted modules */

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

     * Get permitted modules.

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

        return static::$permittedModules = $modules;

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 (\App\Cache::has('API-FieldPermission', $cacheName)) {

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

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

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

    }

There are no issues that match your filters.

Category
Status