YetiForceCompany/YetiForceCRM

View on GitHub
app/SystemWarnings/Mail/CheckSuspendedAccounts.php

Summary

Maintainability
A
0 mins
Test Coverage
F
37%

Missing class import via use statement (line '32', column '16').
Open

        $data = (new \App\Db\Query())->select(['username', 'crm_status'])->from('roundcube_users')

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

                $label = \App\Language::translate(\OSSMail_Record_Model::getStatusLabel($row['crm_status']), 'OSSMailScanner');

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::translateArgs('LBL_CHECK_SUSPENDED_ACCOUNTS_DESC', 'Settings:SystemWarnings', $userSuspendedList);

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

        } elseif (\App\Security\AdminAccess::isPermitted('OSSMailScanner')) {

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

                $label = \App\Language::translate(\OSSMail_Record_Model::getStatusLabel($row['crm_status']), 'OSSMailScanner');

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('OSSMailScanner', 'Settings:OSSMailScanner');

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

        } elseif (\App\Security\AdminAccess::isPermitted('OSSMailScanner')) {

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

        $data = (new \App\Db\Query())->select(['username', 'crm_status'])->from('roundcube_users')

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

        $data = (new \App\Db\Query())->select(['username', 'crm_status'])->from('roundcube_users')

Reference to undeclared property \App\SystemWarnings\Mail\CheckSuspendedAccounts->linkTitle
Open

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

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 = 0;

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

        $data = (new \App\Db\Query())->select(['username', 'crm_status'])->from('roundcube_users')

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

     */

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

            ->where(['crm_status' => [\OSSMail_Record_Model::MAIL_BOX_STATUS_BLOCKED_TEMP, \OSSMail_Record_Model::MAIL_BOX_STATUS_BLOCKED_PERM]])

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 (!$data) {

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

        } elseif (\App\Security\AdminAccess::isPermitted('OSSMailScanner')) {

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

            $userSuspendedList .= '<ul>';

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

     * Checks for suspended email accounts.

Line exceeds 120 characters; contains 145 characters
Open

            ->where(['crm_status' => [\OSSMail_Record_Model::MAIL_BOX_STATUS_BLOCKED_TEMP, \OSSMail_Record_Model::MAIL_BOX_STATUS_BLOCKED_PERM]])

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

            ->all();

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

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

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

    protected $title = 'LBL_CHECK_SUSPENDED_ACCOUNTS';

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

                $label = \App\Language::translate(\OSSMail_Record_Model::getStatusLabel($row['crm_status']), 'OSSMailScanner');

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

                $userSuspendedList .= "<li> {$row['username']} - {$label} </li>";

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

            $userSuspendedList = '<ul>';

Line exceeds 120 characters; contains 146 characters
Open

            $this->description = \App\Language::translateArgs('LBL_CHECK_SUSPENDED_ACCOUNTS_DESC', 'Settings:SystemWarnings', $userSuspendedList);

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

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

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

            $this->description = \App\Language::translateArgs('LBL_CHECK_SUSPENDED_ACCOUNTS_DESC', 'Settings:SystemWarnings', $userSuspendedList);

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

            foreach ($data as $row) {

Line exceeds 120 characters; contains 127 characters
Open

                $label = \App\Language::translate(\OSSMail_Record_Model::getStatusLabel($row['crm_status']), 'OSSMailScanner');

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

    }

There are no issues that match your filters.

Category
Status