YetiForceCompany/YetiForceCRM

View on GitHub
app/SystemWarnings/Security/Dependencies.php

Summary

Maintainability
A
1 hr
Test Coverage
F
21%

Function process has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function process(): void
    {
        try {
            $checker = (new \App\Security\Dependency())->securityChecker();
            $this->status = $checker ? 0 : 1;
Severity: Minor
Found in app/SystemWarnings/Security/Dependencies.php - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

            $checker = (new \App\Security\Dependency())->securityChecker();

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\Security\AdminAccess' in method 'process'.
Open

            if (\App\Security\AdminAccess::isPermitted('Dependencies')) {

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

                $this->linkTitle = \App\Language::translate('Security', 'Settings:SystemWarnings');

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

            $this->description = \App\Language::translate('LBL_VULNERABILITIES_IN_DEPENDENCIES_DESC', 'Settings:SystemWarnings') . '<br />';

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

                $this->description .= '<h3><u>' . \App\Language::translate("LBL_SECURITY_{$type}", 'Settings:Dependencies') . ':</u></h3><br />';

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

Reference to undeclared property \App\SystemWarnings\Security\Dependencies->linkTitle
Open

                $this->linkTitle = \App\Language::translate('Security', 'Settings:SystemWarnings');

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 process(): void

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

            $checker = (new \App\Security\Dependency())->securityChecker();

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

                $this->link = 'index.php?module=Dependencies&parent=Settings&view=Vulnerabilities';

Line exceeds 120 characters; contains 176 characters
Open

                        $this->description .= "<li><h5><a rel=\"noreferrer noopener\" target=\"_blank\" href=\"{$data['link']}\">{$data['cve']}</a></h5> {$data['title']}</li>";

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

            $this->status = $checker ? 0 : 1;

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

    protected $priority = 9;

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->status = 1;

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

        try {

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

                foreach ($vulnerabilities as $name => $vulnerability) {

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

                    $this->description .= "<h4>$name ({$vulnerability['version']}):</h4><br />";

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

    protected $title = 'LBL_VULNERABILITIES_IN_DEPENDENCIES';

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\Security\AdminAccess::isPermitted('Dependencies')) {

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

                        $this->description .= "<li><h5><a rel=\"noreferrer noopener\" target=\"_blank\" href=\"{$data['link']}\">{$data['cve']}</a></h5> {$data['title']}</li>";

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

     * Checks if encryption is active.

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

            $this->description = \App\Language::translate('LBL_VULNERABILITIES_IN_DEPENDENCIES_DESC', 'Settings:SystemWarnings') . '<br />';

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

                $this->description .= '<h3><u>' . \App\Language::translate("LBL_SECURITY_{$type}", 'Settings:Dependencies') . ':</u></h3><br />';

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

                $this->linkTitle = \App\Language::translate('Security', 'Settings:SystemWarnings');

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

        } catch (\Throwable $e) {

Line exceeds 120 characters; contains 140 characters
Open

            $this->description = \App\Language::translate('LBL_VULNERABILITIES_IN_DEPENDENCIES_DESC', 'Settings:SystemWarnings') . '<br />';

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

     * @return void

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

            foreach ($checker as $type => $vulnerabilities) {

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

                    foreach ($vulnerability['advisories'] as $data) {

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

                    $this->description .= '</ul><hr />';

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

        if (0 === $this->status) {

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

                $type = strtoupper($type);

Line exceeds 120 characters; contains 145 characters
Open

                $this->description .= '<h3><u>' . \App\Language::translate("LBL_SECURITY_{$type}", 'Settings:Dependencies') . ':</u></h3><br />';

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

                    $this->description .= '<ul>';

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

                    }

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

    }

There are no issues that match your filters.

Category
Status