YetiForceCompany/YetiForceCRM

View on GitHub
app/Exceptions/NoPermittedForAdmin.php

Summary

Maintainability
B
5 hrs
Test Coverage
F
0%

__construct accesses the super-global variable $_REQUEST.
Open

    public function __construct($message = '', $code = 406, \Exception $previous = null)
    {
        parent::__construct($message, $code, $previous);
        \App\Session::init();
        $request = \App\Request::init();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

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

            'request' => json_encode((new \App\Anonymization())->setModuleName($request->getModule())->setData($_REQUEST)->anonymize()->getData()),

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\TextUtils' in method '__construct'.
Open

            'ip' => \App\TextUtils::textTruncate(\App\RequestUtil::getRemoteIP(), 100, false),

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\Session' in method '__construct'.
Open

        \App\Session::init();

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\TextUtils' in method '__construct'.
Open

            'url' => \App\TextUtils::textTruncate(\App\RequestUtil::getBrowserInfo()->url, 300, false),

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\TextUtils' in method '__construct'.
Open

            'agent' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_USER_AGENT', '-'), 500, false),

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\Request' in method '__construct'.
Open

        $request = \App\Request::init();

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\Session' in method '__construct'.
Open

        $userName = \App\Session::get('full_user_name');

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\Request' in method '__construct'.
Open

            'agent' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_USER_AGENT', '-'), 500, false),

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\RequestUtil' in method '__construct'.
Open

            'ip' => \App\TextUtils::textTruncate(\App\RequestUtil::getRemoteIP(), 100, false),

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\TextUtils' in method '__construct'.
Open

            'referer' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_REFERER', '-'), 300, false),

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\Request' in method '__construct'.
Open

            'referer' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_REFERER', '-'), 300, false),

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 \App\Db::createCommand
Open

        \App\Db::getInstance('log')->createCommand()->insert('o_#__access_for_admin', $data)->execute();
Severity: Critical
Found in app/Exceptions/NoPermittedForAdmin.php by phan

Doc-block of $previous in __construct is phpdoc param type \Exception which is not a permitted replacement of the nullable param type ?\Exception declared in the signature ('?T' should be documented as 'T|null' or '?T')
Open

     * @param \Exception $previous
Severity: Minor
Found in app/Exceptions/NoPermittedForAdmin.php by phan

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        $data = [
            'username' => empty($userName) ? '-' : $userName,
            'date' => date('Y-m-d H:i:s'),
            'ip' => \App\TextUtils::textTruncate(\App\RequestUtil::getRemoteIP(), 100, false),
            'module' => $request->getModule(),
Severity: Major
Found in app/Exceptions/NoPermittedForAdmin.php and 1 other location - About 5 hrs to fix
app/Exceptions/NoPermitted.php on lines 23..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 186.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        $request = \App\Request::init();

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

        ];

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

            'referer' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_REFERER', '-'), 300, false),

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

            'username' => empty($userName) ? '-' : $userName,

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

    {

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

        $data = [

Line exceeds 120 characters; contains 147 characters
Open

            'request' => json_encode((new \App\Anonymization())->setModuleName($request->getModule())->setData($_REQUEST)->anonymize()->getData()),

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

        \App\Db::getInstance('log')->createCommand()->insert('o_#__access_for_admin', $data)->execute();

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

     * @param int        $code

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

            'module' => $request->getModule(),

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

            'request' => json_encode((new \App\Anonymization())->setModuleName($request->getModule())->setData($_REQUEST)->anonymize()->getData()),

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

     *

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

            'date' => 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

        parent::__construct($message, $code, $previous);

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

            'agent' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_USER_AGENT', '-'), 500, false),

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

        $userName = \App\Session::get('full_user_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

    /**

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

     * @param string     $message

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

            'ip' => \App\TextUtils::textTruncate(\App\RequestUtil::getRemoteIP(), 100, false),

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

            'url' => \App\TextUtils::textTruncate(\App\RequestUtil::getBrowserInfo()->url, 300, false),

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

     * @param \Exception $previous

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

    public function __construct($message = '', $code = 406, \Exception $previous = null)

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

        \App\Session::init();

There are no issues that match your filters.

Category
Status