Avoid using static access to class '\Settings_Calendar_Module_Model' in method 'testUpdateCalendarConfig'. Open
$result = \Settings_Calendar_Module_Model::getCalendarConfig('reminder');
- 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_Calendar_Module_Model' in method 'testResetToDefault'. Open
\Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 0, 'id' => 'update_event']);
- 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_Calendar_Module_Model' in method 'testResetToDefault'. Open
$result = \Settings_Calendar_Module_Model::getNotWorkingDays();
- 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_Calendar_Module_Model' in method 'testUpdateCalendarConfig'. Open
\Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 1, 'id' => 'update_event']);
- 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 'testResetToDefault'. Open
\App\Cache::clear();
- 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_Calendar_Module_Model' in method 'testResetToDefault'. Open
\Settings_Calendar_Module_Model::updateNotWorkingDays(['val' => $referenceNotWorkingDays]);
- 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 'testGetPicklistValue'. Open
\App\Cache::clear();
- 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_Calendar_Module_Model' in method 'testUpdateNotWorkingDays'. Open
$result = \Settings_Calendar_Module_Model::getNotWorkingDays();
- 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_Calendar_Module_Model' in method 'testUpdateNotWorkingDays'. Open
\Settings_Calendar_Module_Model::updateNotWorkingDays(['val' => $referenceData]);
- 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_Calendar_Module_Model' in method 'testGetPicklistValue'. Open
$this->assertGreaterThan(0, (\count(\Settings_Calendar_Module_Model::getPicklistValue())), 'Calendar activity type picklist is empty');
- 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_Calendar_Module_Model' in method 'testResetToDefault'. Open
$result = \Settings_Calendar_Module_Model::getCalendarConfig('reminder');
- 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 "update_event" 4 times. Open
\Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 1, 'id' => 'update_event']);
- 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 "color" 3 times. Open
\Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 1, 'id' => 'update_event']);
- 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
\App\Db::getInstance()->createCommand()->delete('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar'])->execute();
- Exclude checks
Call to undeclared method \Tests\Settings\Calendar::assertSame
Open
$this->assertSame((int) $row['value'], 0, 'Calendar config value is different than provided');
- Exclude checks
Call to undeclared method \Tests\Settings\Calendar::assertTrue
Open
$this->assertTrue($found, 'Calendar config option not found');
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->insert('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar', 'presence' => 1, 'sortorderid' => 99, 'color' => 'A0B584'])->execute();
- Exclude checks
Call to undeclared method \Tests\Settings\Calendar::assertGreaterThan
Open
$this->assertGreaterThan(0, (\count(\Settings_Calendar_Module_Model::getPicklistValue())), 'Calendar activity type picklist is empty');
- Exclude checks
Call to undeclared method \Tests\Settings\Calendar::assertSame
Open
$this->assertSame($result, $referenceNotWorkingDays, 'Not working days should be empty');
- Exclude checks
Call to undeclared method \Tests\Settings\Calendar::assertSame
Open
$this->assertSame((int) $row['value'], 1, 'Calendar config value is different than provided');
- Exclude checks
Call to undeclared method \Tests\Settings\Calendar::assertTrue
Open
$this->assertTrue($found, 'Calendar config option not found');
- Exclude checks
Call to undeclared method \Tests\Settings\Calendar::assertSame
Open
$this->assertSame($result, $referenceData, 'Not working days differs from provided');
- Exclude checks
Avoid excessively long variable names like $referenceNotWorkingDays. Keep variable name length under 20. Open
$referenceNotWorkingDays = [];
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Spaces must be used to indent lines; tabs are not allowed Open
public function testUpdateCalendarConfig()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($result as $row) {
- 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->assertTrue($found, 'Calendar config option not found');
- 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
$referenceData = ['1', '3'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($result, $referenceData, 'Not working days differs from provided');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->createCommand()->delete('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar'])->execute();
- 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
$result = \Settings_Calendar_Module_Model::getNotWorkingDays();
- 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
\Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 0, 'id' => 'update_event']);
- 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
$found = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertGreaterThan(0, (\count(\Settings_Calendar_Module_Model::getPicklistValue())), 'Calendar activity type picklist is empty');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((int) $row['value'], 0, 'Calendar config value is different than provided');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$referenceNotWorkingDays = [];
- Exclude checks
Line exceeds 120 characters; contains 190 characters Open
\App\Db::getInstance()->createCommand()->insert('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar', 'presence' => 1, 'sortorderid' => 99, 'color' => 'A0B584'])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\Settings_Calendar_Module_Model::updateNotWorkingDays(['val' => $referenceNotWorkingDays]);
- 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 testUpdateNotWorkingDays()
- 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 testResetToDefault()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::clear();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('update_event' === $row['name']) {
- 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
foreach ($result as $row) {
- 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
$result = \Settings_Calendar_Module_Model::getCalendarConfig('reminder');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((int) $row['value'], 1, 'Calendar config value is different than provided');
- 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
\Settings_Calendar_Module_Model::updateNotWorkingDays(['val' => $referenceData]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Reset to default values.
- 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 testGetPicklistValue()
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
$this->assertGreaterThan(0, (\count(\Settings_Calendar_Module_Model::getPicklistValue())), 'Calendar activity type picklist is empty');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing calendar config save.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 1, 'id' => 'update_event']);
- 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
$result = \Settings_Calendar_Module_Model::getCalendarConfig('reminder');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('update_event' === $row['name']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = \Settings_Calendar_Module_Model::getNotWorkingDays();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$found = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing getPicklistValue method.
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
\App\Db::getInstance()->createCommand()->delete('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar'])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$found = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing not working days config save.
- 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->assertSame($result, $referenceNotWorkingDays, 'Not working days should be empty');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue($found, 'Calendar config option not found');
- 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\Db::getInstance()->createCommand()->insert('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar', 'presence' => 1, 'sortorderid' => 99, 'color' => 'A0B584'])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::clear();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$found = false;
- Exclude checks