setUpBeforeClass accesses the super-global variable $_SERVER. Open
public static function setUpBeforeClass(): void
{
if (!empty($_SERVER['YETI_MAIL_PASS'])) {
$db = \App\Db::getInstance();
$db->createCommand()
- Read upRead up
- Exclude checks
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
setUpBeforeClass accesses the super-global variable $_SERVER. Open
public static function setUpBeforeClass(): void
{
if (!empty($_SERVER['YETI_MAIL_PASS'])) {
$db = \App\Db::getInstance();
$db->createCommand()
- Read upRead up
- Exclude checks
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
Method setUpBeforeClass
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function setUpBeforeClass(): void
{
if (!empty($_SERVER['YETI_MAIL_PASS'])) {
$db = \App\Db::getInstance();
$db->createCommand()
Missing class import via use statement (line '46', column '16'). Open
$row = (new \App\Db\Query())
- 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 '76', column '27'). Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_cron_task')->where(['status' => 2])->exists());
- 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 '70', column '16'). Open
$rows = (new \App\Db\Query())->select(['modue' => 'setype', 'rows' => 'count(*)'])->from('vtiger_crmentity')->groupBy('setype')->orderBy(['rows' => SORT_DESC])->all();
- 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\Cron' in method 'test'. Open
\App\Cron::updateStatus(\App\Cron::STATUS_DISABLED, 'LBL_UPDATER_COORDINATES');
- 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\Cron' in method 'test'. Open
\App\Cron::updateStatus(\App\Cron::STATUS_DISABLED, 'LBL_MAIL_SCANNER_ACTION');
- 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 '\Settings_CronTasks_Module_Model' in method 'testGetLastCronStart'. Open
$module = \Settings_CronTasks_Module_Model::getInstance('Settings:CronTasks');
- 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 'setUpBeforeClass'. Open
$db = \App\Db::getInstance();
- 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\Cron' in method 'test'. Open
\App\Cron::updateStatus(\App\Cron::STATUS_DISABLED, 'LBK_SYSTEM_WARNINGS');
- 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\Cron' in method 'test'. Open
\App\Cron::updateStatus(\App\Cron::STATUS_DISABLED, 'LBL_UPDATER_RECORDS_COORDINATES');
- 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
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()
- Exclude checks
Call to undeclared method \Tests\Base\G_Cron::assertFalse
Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_cron_task')->where(['status' => 2])->exists());
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$rows = (new \App\Db\Query())->select(['modue' => 'setype', 'rows' => 'count(*)'])->from('vtiger_crmentity')->groupBy('setype')->orderBy(['rows' => SORT_DESC])->all();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->insert('vtiger_currency_info', $row)->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_cron_task')->where(['status' => 2])->exists());
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$row = (new \App\Db\Query())
- Exclude checks
Call to undeclared method \Tests\Base\G_Cron::assertNotSame
Open
$this->assertNotSame(0, $module->getLastCronStart(), 'Last cron start is 0');
- Exclude checks
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = \App\Db::getInstance();
- 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
Avoid variables with short names like $c. Configured minimum length is 3. Open
$c = '';
- 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
The class G_Cron is not named in CamelCase. Open
class G_Cron extends \Tests\Base
{
/**
* Prepare mail config for mail functionalities.
*
- 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
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->insert('vtiger_ossmailscanner_folders_uid', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cron::updateStatus(\App\Cron::STATUS_DISABLED, 'LBK_SYSTEM_WARNINGS');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testGetLastCronStart(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'folder' => 'INBOX',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rows as $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->createCommand()->insert('vtiger_currency_info', $row)->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function test(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Prepare mail config for mail functionalities.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function setUpBeforeClass(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'password' => $_SERVER['YETI_MAIL_PASS'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['vtiger_currencies.currency_code' => $value, 'vtiger_currency_info.currency_code' => null])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$module = \Settings_CronTasks_Module_Model::getInstance('Settings:CronTasks');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
->leftJoin('vtiger_currency_info', 'vtiger_currencies.currency_code = vtiger_currency_info.currency_code')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_cron_task')->where(['status' => 2])->exists());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($row['currencyid']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @codeCoverageIgnore
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'language' => 'en_US',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (['EUR', 'USD', 'GBP', 'CNY'] as $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\file_put_contents(ROOT_DIRECTORY . '/tests/records.log', $c . PHP_EOL, FILE_APPEND);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'user_id' => '1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['conversion_rate'] = 1;
- Exclude checks
Line exceeds 120 characters; contains 175 characters Open
$rows = (new \App\Db\Query())->select(['modue' => 'setype', 'rows' => 'count(*)'])->from('vtiger_crmentity')->groupBy('setype')->orderBy(['rows' => SORT_DESC])->all();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'actions' => 'CreatedEmail,CreatedHelpDesk,BindAccounts,BindContacts,BindLeads,BindHelpDesk,BindSSalesProcesses,BindCampaigns,BindCompetition,BindOSSEmployees,BindPartners,BindProject,BindServiceContracts,BindVendors',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Cron testing.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new \App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_currencies')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('vtiger_currency_info', 'vtiger_currencies.currency_code = vtiger_currency_info.currency_code')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing last cron start getter.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cron::updateStatus(\App\Cron::STATUS_DISABLED, 'LBL_MAIL_SCANNER_ACTION');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$c = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'uid' => '0',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cron::updateStatus(\App\Cron::STATUS_DISABLED, 'LBL_UPDATER_COORDINATES');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rows = (new \App\Db\Query())->select(['modue' => 'setype', 'rows' => 'count(*)'])->from('vtiger_crmentity')->groupBy('setype')->orderBy(['rows' => SORT_DESC])->all();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'mail_host' => 'imap.mail.yahoo.com',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'crm_user_id' => '1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['vtiger_currencies.*'])
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
->where(['vtiger_currencies.currency_code' => $value, 'vtiger_currency_info.currency_code' => null])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($_SERVER['YETI_MAIL_PASS'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->insert('roundcube_users', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'preferences' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cron::updateStatus(\App\Cron::STATUS_DISABLED, 'LBL_UPDATER_RECORDS_COORDINATES');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'username' => 'yetiforcetests@yahoo.com',
- Exclude checks
Line exceeds 120 characters; contains 238 characters Open
'actions' => 'CreatedEmail,CreatedHelpDesk,BindAccounts,BindContacts,BindLeads,BindHelpDesk,BindSSalesProcesses,BindCampaigns,BindCompetition,BindOSSEmployees,BindPartners,BindProject,BindServiceContracts,BindVendors',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'type' => 'Received',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['currency_status'] = 'Active';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
require_once 'cron.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$c .= "{$value['modue']} = {$value['rows']}, | ";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotSame(0, $module->getLastCronStart(), 'Last cron start is 0');
- Exclude checks
Class name "G_Cron" is not in camel caps format Open
class G_Cron extends \Tests\Base
- Exclude checks