Missing class import via use statement (line '31', column '52'). Open
$this->logs = $dbSequence = $testSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
- 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 '37', column '27'). Open
$currentSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
- 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 '\Settings_CronTasks_Module_Model' in method 'testGetLastCronIteration'. 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 '\Settings_CronTasks_Record_Model' in method 'testRecordInstance'. Open
$recordModel = \Settings_CronTasks_Record_Model::getInstanceByName('LBL_BROWSING_HISTORY');
- 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 'testUpdateTasksSequence'. Open
$moduleModel = \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
Define a constant instead of duplicating this literal "status" 3 times. Open
$this->logs = $dbSequence = $testSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
- 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 \Tests\Settings\CronTasks::AssertSame
Open
$this->AssertSame('LBL_BROWSING_HISTORY', $recordModel->getName());
- Exclude checks
Call to undeclared method \Tests\Settings\CronTasks::AssertNotEmpty
Open
$this->AssertNotEmpty($recordModel->getDuration(), 'Returned duration should be not empty');
- Exclude checks
Call to undeclared method \Tests\Settings\CronTasks::assertIsInt
Open
$this->assertIsInt($recordModel->getTimeDiff(), 'Returned time difference should be integer');
- Exclude checks
Call to undeclared method \Tests\Settings\CronTasks::AssertNotEmpty
Open
$this->AssertNotEmpty($recordModel->getDisplayValue($fieldName), 'Field ' . $fieldName . ' returned empty value');
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$this->logs = $dbSequence = $testSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$currentSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
- Exclude checks
Call to undeclared method \Tests\Settings\CronTasks::assertSame
Open
$this->assertSame($testSequence, $currentSequence, 'Current sequence is different from provided');
- Exclude checks
Call to undeclared method \Tests\Settings\CronTasks::assertNotEmpty
Open
$this->assertNotEmpty($module->getLastCronIteration(), 'Last cron iteration should be not empty');
- Exclude checks
Expected 1 space before "as"; 0 found Open
foreach (['frequency', 'status', 'name', 'duration']as $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
$this->AssertNotEmpty($recordModel->getDisplayValue($fieldName), 'Field ' . $fieldName . ' returned empty 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
$moduleModel = \Settings_CronTasks_Module_Model::getInstance('Settings:CronTasks');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$testSequence[1] = $testSequence[2];
- 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
public function testGetLastCronIteration()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->AssertSame('LBL_BROWSING_HISTORY', $recordModel->getName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$testSequence[2] = $tmp;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testRecordInstance()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = \Settings_CronTasks_Record_Model::getInstanceByName('LBL_BROWSING_HISTORY');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing last cron iteration getter.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($testSequence, $currentSequence, 'Current sequence is different from provided');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotEmpty($module->getLastCronIteration(), 'Last cron iteration should be not empty');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (['frequency', 'status', 'name', 'duration']as $fieldName) {
- 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->assertIsInt($recordModel->getTimeDiff(), 'Returned time difference should be integer');
- 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
$this->AssertNotEmpty($recordModel->getDuration(), 'Returned duration should be not empty');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 214 characters Open
$this->logs = $dbSequence = $testSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->updateSequence($testSequence);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->updateSequence($dbSequence);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->logs = $dbSequence = $testSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
- Exclude checks
Line exceeds 120 characters; contains 189 characters Open
$currentSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->AssertNotEmpty($recordModel->getDisplayValue($fieldName), 'Field ' . $fieldName . ' returned empty 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing cron tasks sequence update.
- 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
$module = \Settings_CronTasks_Module_Model::getInstance('Settings:CronTasks');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testUpdateTasksSequence()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tmp = $testSequence[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing record instance functions.
- Exclude checks