Avoid using static access to class 'ModTracker_Record_Model' in method 'getWidget'. Open
$this->Config['newChanege'] = ModTracker_Record_Model::isNewChange($this->Record, $currentUser->getRealId());
- 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 'Users_Record_Model' in method 'getWidget'. Open
$currentUser = Users_Record_Model::getCurrentUserModel();
- 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\Language' in method 'getWidget'. Open
$this->Config['switchHeaderLables']['on'] = \App\Language::translate('LBL_UPDATES', $moduleName);
- 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\Language' in method 'getWidget'. Open
$this->Config['switchHeaderLables']['off'] = \App\Language::translate('LBL_REVIEW_HISTORY', $moduleName);
- 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 "switchHeader" 3 times. Open
$this->Config['switchHeader'] = [];
- 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.
Suspicious type false
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showRecentActivities&page=1&limit=5&skipHeader=true';
- Exclude checks
Argument 1 (recordId)
is false
but \ModTracker_Record_Model::isNewChange()
takes int
defined at /code/modules/ModTracker/models/Record.php:142
Open
$this->Config['newChanege'] = ModTracker_Record_Model::isNewChange($this->Record, $currentUser->getRealId());
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_Updates_Widget extends Vtiger_Basic_Widget
- Exclude checks
The class Vtiger_Updates_Widget is not named in CamelCase. Open
class Vtiger_Updates_Widget extends Vtiger_Basic_Widget
{
public function getUrl()
{
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showRecentActivities&page=1&limit=5&skipHeader=true';
- 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
public function getUrl()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->Config;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getWidget()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['url'] = $this->getUrl();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['switchHeaderLables']['on'] = \App\Language::translate('LBL_UPDATES', $moduleName);
- 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->Config['switchHeaderLables']['off'] = \App\Language::translate('LBL_REVIEW_HISTORY', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentUser = Users_Record_Model::getCurrentUserModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['switchHeader'] = [];
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showRecentActivities&page=1&limit=5&skipHeader=true';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['switchHeader']['off'] = 'review';
- 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
$moduleName = 'ModTracker';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['newChanege'] = ModTracker_Record_Model::isNewChange($this->Record, $currentUser->getRealId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['switchHeader']['on'] = 'changes';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['moduleBaseName'] = $moduleName;
- 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
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=showRecentActivities&page=1&limit=5&skipHeader=true';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['tpl'] = 'Updates.tpl';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Class name "Vtiger_Updates_Widget" is not in camel caps format Open
class Vtiger_Updates_Widget extends Vtiger_Basic_Widget
- Exclude checks