Method process
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$db = \App\Db::getInstance('admin');
$dbCommand = $db->createCommand();
if (\in_array($request->getMode(), ['forVerification', 'toSend', 'request'])) {
Missing class import via use statement (line '46', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '27', column '16'). Open
$row = (new \App\Db\Query())->from('s_#__mail_rbl_list')->where(['request' => $request->getInteger('record')])->one($db);
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '36', column '16'). Open
$row = (new \App\Db\Query())->from('s_#__mail_rbl_list')->where(['id' => $request->getInteger('record')])->one($db);
- Read upRead up
- Exclude checks
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 'process'. Open
\App\Cache::delete('MailRblIpColor', $row['ip']);
- Read upRead up
- Exclude checks
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\Db' in method 'process'. Open
$db = \App\Db::getInstance('admin');
- Read upRead up
- Exclude checks
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 'process'. Open
\App\Cache::delete('MailRblList', $row['ip']);
- Read upRead up
- Exclude checks
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 'process'. Open
\App\Cache::delete('MailRblIpColor', $row['ip']);
- Read upRead up
- Exclude checks
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
The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$row = (new \App\Db\Query())->from('s_#__mail_rbl_list')->where(['id' => $request->getInteger('record')])->one($db);
$status = $dbCommand->delete('s_#__mail_rbl_list', [
'id' => $request->getInteger('record')
])->execute();
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Cache' in method 'process'. Open
\App\Cache::delete('MailRblList', $row['ip']);
- Read upRead up
- Exclude checks
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 "record" 5 times. Open
'id' => $request->getInteger('record')
- Read upRead up
- Exclude checks
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 "request" 4 times. Open
if (\in_array($request->getMode(), ['forVerification', 'toSend', 'request'])) {
- Read upRead up
- Exclude checks
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 "s_#__mail_rbl_list" 4 times. Open
$row = (new \App\Db\Query())->from('s_#__mail_rbl_list')->where(['request' => $request->getInteger('record')])->one($db);
- Read upRead up
- Exclude checks
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
$dbCommand = $db->createCommand();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new \App\Db\Query())->from('s_#__mail_rbl_list')->where(['request' => $request->getInteger('record')])->one($db);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new \App\Db\Query())->from('s_#__mail_rbl_list')->where(['id' => $request->getInteger('record')])->one($db);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_MailRbl_DeleteAjax_Action extends Settings_Vtiger_Delete_Action
- Exclude checks
The class Settings_MailRbl_DeleteAjax_Action is not named in CamelCase. Open
class Settings_MailRbl_DeleteAjax_Action extends Settings_Vtiger_Delete_Action
{
/** {@inheritdoc} */
public function process(App\Request $request)
{
- Read upRead up
- Exclude checks
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('admin');
- Read upRead up
- Exclude checks
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 for alignment; tabs are not allowed Open
$dbCommand = $db->createCommand();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (\in_array($request->getMode(), ['forVerification', 'toSend', 'request'])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Cache::delete('MailRblIpColor', $row['ip']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$row = (new \App\Db\Query())->from('s_#__mail_rbl_list')->where(['request' => $request->getInteger('record')])->one($db);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'id' => $request->getInteger('record')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$status = $dbCommand->delete('s_#__mail_rbl_list', [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$row = (new \App\Db\Query())->from('s_#__mail_rbl_list')->where(['id' => $request->getInteger('record')])->one($db);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @license YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($row) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->delete('s_#__mail_rbl_list', [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'request' => $request->getInteger('record')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Cache::delete('MailRblList', $row['ip']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->update('s_#__mail_rbl_request', [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response->setResult($status);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
], ['id' => $row['request']])->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Cache::delete('MailRblIpColor', $row['ip']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function process(App\Request $request)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$db = \App\Db::getInstance('admin');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$status = $dbCommand->delete('s_#__mail_rbl_request', [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Cache::delete('MailRblList', $row['ip']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'status' => 3,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'id' => $request->getInteger('record')
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
$row = (new \App\Db\Query())->from('s_#__mail_rbl_list')->where(['request' => $request->getInteger('record')])->one($db);
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
$row = (new \App\Db\Query())->from('s_#__mail_rbl_list')->where(['id' => $request->getInteger('record')])->one($db);
- Exclude checks
Class name "Settings_MailRbl_DeleteAjax_Action" is not in camel caps format Open
class Settings_MailRbl_DeleteAjax_Action extends Settings_Vtiger_Delete_Action
- Exclude checks